Ejemplo n.º 1
0
def test__build_job_explanation():
    iu = InventoryUpdate(id=3, name='I_am_an_Inventory_Update')

    job_explanation = iu._build_job_explanation()

    assert job_explanation == 'Previous Task Canceled: {"job_type": "%s", "job_name": "%s", "job_id": "%s"}' % \
                              ('inventory_update', 'I_am_an_Inventory_Update', 3)
Ejemplo n.º 2
0
 def test_source_location(self, scm_inventory_source):
     # Combines project directory with the inventory file specified
     inventory_update = InventoryUpdate(
         inventory_source=scm_inventory_source,
         source_path=scm_inventory_source.source_path)
     assert inventory_update.get_actual_source_path().endswith(
         '_92__test_proj/inventory_file')
Ejemplo n.º 3
0
def test_inventory_update_event_websocket_notifications(emit, inventory):
    source = InventorySource()
    source.save()
    iu = InventoryUpdate(id=123, inventory_source=source)
    iu.save()
    InventoryUpdateEvent.create_from_data(inventory_update_id=iu.pk)
    assert len(emit.call_args_list) == 1
    topic, payload = emit.call_args_list[0][0]
    assert topic == 'inventory_update_events-123'
    assert payload['inventory_update'] == 123
Ejemplo n.º 4
0
def _mk_inventory_update(created=None):
    kwargs = {}
    if created:
        kwargs['created'] = created
    source = InventorySource(source='ec2')
    source.save()
    iu = InventoryUpdate(inventory_source=source, source='e2', **kwargs)
    return iu
Ejemplo n.º 5
0
def test_cancel(mocker):
    with mock.patch.object(UnifiedJob, 'cancel', return_value=True) as parent_cancel:
        iu = InventoryUpdate()

        iu.save = mocker.MagicMock()
        build_job_explanation_mock = mocker.MagicMock()
        iu._build_job_explanation = mocker.MagicMock(return_value=build_job_explanation_mock)

        iu.cancel()

        parent_cancel.assert_called_with(is_chain=False, job_explanation=None)
Ejemplo n.º 6
0
 def test_inventory_friend_cancel(self, inventory, admin_user, inv_updater):
     inventory_update = InventoryUpdate(inventory_source=InventorySource(
         name=inventory.name, inventory=inventory, source='gce'),
                                        created_by=admin_user)
     access = InventoryUpdateAccess(inv_updater)
     assert not access.can_cancel(inventory_update)
def _mk_inventory_update():
    source = InventorySource()
    source.save()
    iu = InventoryUpdate(inventory_source=source)
    return iu
def _mk_inventory_update():
    source = InventorySource(source='ec2')
    source.save()
    iu = InventoryUpdate(inventory_source=source, source='e2')
    return iu