Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_duplicate_host(self):
host = m.Host(
name='localhost',
playbook=self.playbook,
)
m.db.session.add(host)
with self.assertRaises(Exception):
m.db.session.commit()
def test_duplicate_host(self):
host = m.Host(
name='localhost',
playbook=self.playbook,
)
m.db.session.add(host)
with self.assertRaises(Exception):
m.db.session.commit()
result = m.TaskResult(task=task, status='ok', host=host, result=msg)
ctx = dict(
playbook=playbook,
play=play,
file=playbook_file,
task=task,
host=host,
result=result)
if gather_facts:
facts = m.HostFacts(host=host, values='{"fact": "value"}')
ctx['facts'] = facts
if ara_record:
data = m.Data(playbook=playbook, key='test key', value='test value')
ctx['data'] = data
for obj in ctx.values():
if hasattr(obj, 'start'):
obj.start()
db.session.add(obj)
db.session.commit()
if complete:
stats = m.Stats(playbook=playbook, host=host)
ctx['stats'] = stats
db.session.add(stats)
ctx['playbook'].complete = True
for obj in ctx.values():
def test_duplicate_data(self):
data = m.Data(
playbook=self.playbook,
key='test key',
value='another value'
)
m.db.session.add(data)
with self.assertRaises(Exception):
m.db.session.commit()
task=task,
host=host,
result=result)
if gather_facts:
facts = m.HostFacts(host=host, values='{"fact": "value"}')
ctx['facts'] = facts
if ara_record:
data = m.Data(playbook=playbook, key='test key', value='test value')
ctx['data'] = data
for obj in ctx.values():
if hasattr(obj, 'start'):
obj.start()
db.session.add(obj)
db.session.commit()
if complete:
stats = m.Stats(playbook=playbook, host=host)
ctx['stats'] = stats
db.session.add(stats)
ctx['playbook'].complete = True
for obj in ctx.values():
if hasattr(obj, 'stop'):
obj.stop()
db.session.commit()
return ctx
host=self.host,
)
self.stats = m.Stats(
playbook=self.playbook,
host=self.host,
changed=0,
failed=0,
skipped=0,
unreachable=0,
ok=0,
)
for obj in [self.playbook, self.play, self.task, self.data,
self.host, self.task_result, self.stats]:
m.db.session.add(obj)
m.db.session.commit()
key: 'test key'
value: 'test value'
when: ara_record
Where `` is a random integer generated each time this
function is called.
Set the `complete` parameter to `False` to simulate an
aborted Ansible run.
Set the `gathered_facts` parameter to `False` to simulate a run with no
facts gathered.
Set the `ara_record` parameter to `True` to simulate a run with an
ara_record task.
'''
playbook = m.Playbook(path='testing.yml')
playbook_file = m.File(path=playbook.path,
playbook=playbook,
is_playbook=True)
play = m.Play(playbook=playbook, name='test play')
host = m.Host(name='host-%04d' % random.randint(0, 9999),
playbook=playbook)
if ara_record:
task = m.Task(play=play, playbook=playbook, action='ara_record')
msg = 'Data recorded in ARA for this playbook.'
else:
task = m.Task(play=play, playbook=playbook, action='test-action')
msg = 'This is a test'
result = m.TaskResult(task=task, status='ok', host=host, result=msg)
def setUp(self):
m.db.create_all()
self.client = self.app.test_client()
def tearDown(self):
m.db.session.remove()
m.db.drop_all()
Set the `gathered_facts` parameter to `False` to simulate a run with no
facts gathered.
Set the `ara_record` parameter to `True` to simulate a run with an
ara_record task.
'''
playbook = m.Playbook(path='testing.yml')
playbook_file = m.File(path=playbook.path,
playbook=playbook,
is_playbook=True)
play = m.Play(playbook=playbook, name='test play')
host = m.Host(name='host-%04d' % random.randint(0, 9999),
playbook=playbook)
if ara_record:
task = m.Task(play=play, playbook=playbook, action='ara_record')
msg = 'Data recorded in ARA for this playbook.'
else:
task = m.Task(play=play, playbook=playbook, action='test-action')
msg = 'This is a test'
result = m.TaskResult(task=task, status='ok', host=host, result=msg)
ctx = dict(
playbook=playbook,
play=play,
file=playbook_file,
task=task,
host=host,
result=result)
if gather_facts: