コード例 #1
0
    def setUp(self):
        super().setUp()
        mocks.init_api_connection(Wrapper)

        # Mock API calls to return values based on what entity
        # is being requested
        mocks.get_field_info_api_calls(
            fixture_utils.manage_sync_picklist_return_data)
        mocks.wrapper_query_api_calls(
            fixture_utils.manage_full_sync_return_data)

        sync_test_cases = [
            TestSyncTicketCommand,
            TestSyncTicketStatusCommand,
            TestSyncResourceCommand,
            TestSyncTicketPriorityCommand,
            TestSyncQueueCommand,
            TestSyncAccountCommand,
            TestSyncProjectCommand,
            TestSyncProjectStatusCommand,
            TestSyncProjectTypeCommand,
            TestSyncTicketCategoryCommand,
            TestSyncSourceCommand,
            TestSyncIssueTypeCommand,
            TestSyncSubIssueTypeCommand,
            TestSyncTicketTypeCommand,
            TestDisplayColorCommand,
            TestLicenseTypeCommand,
        ]

        self.test_args = []

        for test_case in sync_test_cases:
            self.test_args.append(test_case.args)
コード例 #2
0
ファイル: test_sync.py プロジェクト: kti-sam/django-autotask
    def test_evaluate_objects_deleted(self):
        """
        Test that a give object is deleted if not returned during a full sync.
        """
        qset = self.model_class.objects.all()
        self.assertEqual(qset.count(), len(self.fixture))

        # Ensure that the get_field_info method returns no API objects
        # so that the full sync will remove the existing objects in the DB.
        mocks.get_field_info_api_calls()

        synchronizer = self.synchronizer(full=True)
        synchronizer.sync()
        self.assertEqual(qset.count(), 0)
コード例 #3
0
    def setUp(self):
        super().setUp()
        mocks.init_api_connection(Wrapper)
        mocks.create_mock_call(
            'djautotask.sync.TaskSynchronizer._get_query_conditions', None)
        mocks.create_mock_call(
            'djautotask.sync.TicketNoteSynchronizer._get_query_conditions',
            None)
        mocks.create_mock_call(
            'djautotask.sync.TaskNoteSynchronizer._get_query_conditions', None)
        mocks.create_mock_call(
            'djautotask.sync.QueryConditionMixin._get_query_conditions', None)

        # Mock API calls to return values based on what entity
        # is being requested
        mocks.get_field_info_api_calls(
            fixture_utils.manage_sync_picklist_return_data)
        mocks.wrapper_query_api_calls(
            fixture_utils.manage_full_sync_return_data)

        sync_test_cases = [
            TestSyncTicketCommand, TestSyncTaskCommand, TestSyncStatusCommand,
            TestSyncResourceCommand, TestSyncPriorityCommand,
            TestSyncQueueCommand, TestSyncAccountCommand,
            TestSyncProjectCommand, TestSyncProjectStatusCommand,
            TestSyncProjectTypeCommand, TestSyncTicketCategoryCommand,
            TestSyncSourceCommand, TestSyncIssueTypeCommand,
            TestSyncSubIssueTypeCommand, TestSyncTicketTypeCommand,
            TestDisplayColorCommand, TestLicenseTypeCommand,
            TestSyncTaskSecondaryResourceCommand, TestSyncPhaseCommand,
            TestSyncTicketNoteCommand, TestSyncTaskNoteCommand,
            TestSyncTimeEntryCommand, TestSyncTaskTypeLinkCommand,
            TestUseTypeCommand, TestAllocationCodeCommand, TestSyncRoleCommand,
            TestSyncDepartmentCommand, TestResourceRoleDepartmentCommand,
            TestResourceServiceDeskRoleCommand
        ]

        self.test_args = []

        for test_case in sync_test_cases:
            self.test_args.append(test_case.args)
コード例 #4
0
    def test_full_sync(self):
        """Test the command to run a full sync of all objects."""
        at_object_map = {
            'ticket_status': models.TicketStatus,
            'ticket': models.Ticket,
            'resource': models.Resource,
            'ticket_secondary_resource': models.TicketSecondaryResource,
            'ticket_priority': models.TicketPriority,
            'queue': models.Queue,
            'account': models.Account,
            'project': models.Project,
            'project_status': models.ProjectStatus,
            'project_type': models.ProjectType,
            'ticket_category': models.TicketCategory,
            'source': models.Source,
            'issue_type': models.IssueType,
            'sub_issue_type': models.SubIssueType,
            'ticket_type': models.TicketType,
            'display_color': models.DisplayColor,
            'license_type': models.LicenseType,
        }
        run_sync_command()
        pre_full_sync_counts = {}

        # Mock the API request to return no results to ensure
        # objects get deleted.
        mocks.wrapper_query_api_calls()
        mocks.get_field_info_api_calls()

        for key, model_class in at_object_map.items():
            pre_full_sync_counts[key] = model_class.objects.all().count()

        output = run_sync_command(full_option=True)
        for fixture, at_object in self.test_args:
            summary = full_sync_summary(
                slug_to_title(at_object),
                pre_full_sync_counts[at_object.lower()])
            self.assertIn(summary, output.getvalue().strip())
コード例 #5
0
    def test_full_sync(self):
        """Test the command to run a full sync of all objects."""
        at_object_map = {
            'status': models.Status,
            'ticket': models.Ticket,
            'resource': models.Resource,
            'ticket_secondary_resource': models.TicketSecondaryResource,
            'priority': models.Priority,
            'queue': models.Queue,
            'account': models.Account,
            'project': models.Project,
            'project_status': models.ProjectStatus,
            'project_type': models.ProjectType,
            'ticket_category': models.TicketCategory,
            'source': models.Source,
            'issue_type': models.IssueType,
            'sub_issue_type': models.SubIssueType,
            'ticket_type': models.TicketType,
            'display_color': models.DisplayColor,
            'license_type': models.LicenseType,
            'task': models.Task,
            'task_secondary_resource': models.TaskSecondaryResource,
            'phase': models.Phase,
            'ticket_note': models.TicketNote,
            'task_note': models.TaskNote,
            'time_entry': models.TimeEntry,
            'task_type_link': models.TaskTypeLink,
            'use_type': models.UseType,
            'allocation_code': models.AllocationCode,
            'role': models.Role,
            'department': models.Department,
            'resource_role_department': models.ResourceRoleDepartment,
            'resource_service_desk_role': models.ResourceServiceDeskRole,
        }
        run_sync_command()
        pre_full_sync_counts = {}

        mocks.wrapper_query_api_calls()
        mocks.get_field_info_api_calls()
        _, _patch = mocks.build_batch_query()

        for key, model_class in at_object_map.items():
            pre_full_sync_counts[key] = model_class.objects.all().count()

        output = run_sync_command(full_option=True)

        # Verify the rest of sync classes summaries.
        for fixture, at_object in self.test_args:
            if at_object in ('resource_role_department',
                             'resource_service_desk_role'):
                # Assert that there were objects to get deleted, then change
                # to zero to verify the output formats correctly.
                # We are just testing the command, there are sync tests to
                # verify that the syncronizers work correctly
                self.assertGreater(pre_full_sync_counts[at_object], 0)
                pre_full_sync_counts[at_object] = 0
            summary = full_sync_summary(slug_to_title(at_object),
                                        pre_full_sync_counts[at_object])
            self.assertIn(summary, output.getvalue().strip())

        _patch.stop()
コード例 #6
0
    def setUp(self):
        super().setUp()
        mocks.init_api_connection(Wrapper)
        mocks.create_mock_call(
            'djautotask.sync.TicketNoteSynchronizer._get_query_conditions',
            None
        )
        mocks.create_mock_call(
            'djautotask.sync.TaskNoteSynchronizer._get_query_conditions',
            None
        )
        fixture_utils.mock_udfs()
        self._call_service_api()

        # Mock API calls to return values based on what entity
        # is being requested
        mocks.get_field_info_api_calls(
            fixture_utils.manage_sync_picklist_return_data
        )
        mocks.wrapper_query_api_calls(
            fixture_utils.manage_full_sync_return_data
        )

        sync_test_cases = [
            TestSyncLicenseTypeCommand,
            TestSyncTaskTypeLinkCommand,
            TestSyncUseTypeCommand,
            TestSyncAccountTypeCommand,
            TestSyncRoleCommand,
            TestSyncDepartmentCommand,
            TestSyncTicketCommand,
            TestSyncTaskCommand,
            TestSyncStatusCommand,
            TestSyncResourceCommand,
            TestSyncPriorityCommand,
            TestSyncQueueCommand,
            TestSyncAccountCommand,
            TestSyncProjectCommand,
            TestSyncProjectStatusCommand,
            TestSyncProjectTypeCommand,
            TestSyncTicketCategoryCommand,
            TestSyncSourceCommand,
            TestSyncIssueTypeCommand,
            TestSyncSubIssueTypeCommand,
            TestSyncTicketTypeCommand,
            TestDisplayColorCommand,
            TestSyncTaskSecondaryResourceCommand,
            TestSyncPhaseCommand,
            TestSyncTicketNoteCommand,
            TestSyncTaskNoteCommand,
            TestSyncTimeEntryCommand,
            TestAllocationCodeCommand,
            TestResourceRoleDepartmentCommand,
            TestResourceServiceDeskRoleCommand,
            TestContractCommand,
            TestSyncServiceCallStatusCommand,
            TestSyncServiceCallCommand,
            TestSyncServiceCallTicketCommand,
            TestSyncServiceCallTaskCommand,
            TestSyncServiceCallTicketResourceCommand,
            TestSyncServiceCallTaskResourceCommand,
            TestSyncAccountLocationCommand,
            TestSyncTaskPredecessor,
            TestSyncContactCommand,
        ]

        self.test_args = []

        for test_case in sync_test_cases:
            # for REST API
            if len(test_case.args) == 3:
                self.test_args.append(test_case.args)
            # for SOAP API
            else:
                new_test_case = [None, *test_case.args]
                self.test_args.append(new_test_case)