Пример #1
0
    def test_sync_action(self):
        """
        Test with action set to 'sync'.
        """
        context = mock.MagicMock()
        a_task = mock.MagicMock()
        context.server.tasks_search.search.return_value = [a_task]
        repo_id = 'some_repo'
        action = 'sync'

        tasks = sp._get_repo_tasks(context, repo_id, action)

        self.assertEqual(tasks, [a_task])
        expected_repo_tag = tags.resource_tag(tags.RESOURCE_REPOSITORY_TYPE,
                                              repo_id)
        expected_action_tag = tags.action_tag(tags.ACTION_SYNC_TYPE)
        expected_search_criteria = {
            'filters': {
                'state': {
                    '$nin': responses.COMPLETED_STATES
                },
                'tags': {
                    '$all': [expected_repo_tag, expected_action_tag]
                }
            }
        }
        context.server.tasks_search.search.assert_called_once_with(
            **expected_search_criteria)
Пример #2
0
    def test_sync_action(self):
        """
        Test with action set to 'sync'.
        """
        context = mock.MagicMock()
        a_task = mock.MagicMock()
        context.server.tasks_search.search.return_value = [a_task]
        repo_id = 'some_repo'
        action = 'sync'

        tasks = sp._get_repo_tasks(context, repo_id, action)

        self.assertEqual(tasks, [a_task])
        expected_repo_tag = tags.resource_tag(tags.RESOURCE_REPOSITORY_TYPE, repo_id)
        expected_action_tag = tags.action_tag(tags.ACTION_SYNC_TYPE)
        expected_search_criteria = {'filters': {'state': {'$nin': responses.COMPLETED_STATES},
                                                'tags': {'$all': [expected_repo_tag, expected_action_tag]}}}
        context.server.tasks_search.search.assert_called_once_with(**expected_search_criteria)