예제 #1
0
파일: test_tasks.py 프로젝트: doziya/AWX
    def test_dependent_inventory_project_cancel(self, project, inventory):
        '''
        Test that dependent inventory updates exhibit good behavior on cancel
        of the source project update
        '''
        task = RunProjectUpdate()
        proj_update = ProjectUpdate.objects.create(project=project)

        kwargs = dict(
            source_project=project,
            source='scm',
            source_path='inventory_file',
            update_on_project_update=True,
            inventory=inventory
        )

        is1 = InventorySource.objects.create(name="test-scm-inv", **kwargs)
        is2 = InventorySource.objects.create(name="test-scm-inv2", **kwargs)

        def user_cancels_project(pk):
            ProjectUpdate.objects.all().update(cancel_flag=True)

        with mock.patch.object(RunInventoryUpdate, 'run') as iu_run_mock:
            iu_run_mock.side_effect = user_cancels_project
            task._update_dependent_inventories(proj_update, [is1, is2])
            # Verify that it bails after 1st update, detecting a cancel
            assert is2.inventory_updates.count() == 0
            iu_run_mock.assert_called_once()
예제 #2
0
파일: test_tasks.py 프로젝트: doziya/AWX
 def test_dependent_inventory_updates(self, scm_inventory_source):
     task = RunProjectUpdate()
     scm_inventory_source.scm_last_revision = ''
     proj_update = ProjectUpdate.objects.create(project=scm_inventory_source.source_project)
     with mock.patch.object(RunInventoryUpdate, 'run') as iu_run_mock:
         task._update_dependent_inventories(proj_update, [scm_inventory_source])
         assert InventoryUpdate.objects.count() == 1
         inv_update = InventoryUpdate.objects.first()
         iu_run_mock.assert_called_once_with(inv_update.id)
         assert inv_update.source_project_update_id == proj_update.pk