Beispiel #1
0
    def test_finished(self):
        sync_log = SyncLogFactory.create()

        # Create repo without existing log so sync is unfinished.
        repo = RepositoryFactory.create()
        project_sync_log = ProjectSyncLogFactory.create(
            sync_log=sync_log, project__repositories=[repo])

        # Sync isn't finished until all repos are finished.
        assert_false(sync_log.finished)

        repo_log = RepositorySyncLogFactory.create(
            repository=repo,
            project_sync_log=project_sync_log,
            start_time=aware_datetime(2015, 1, 1),
            end_time=None
        )
        del sync_log.finished
        assert_false(sync_log.finished)

        repo_log.end_time = aware_datetime(2015, 1, 2)
        repo_log.save()

        del sync_log.finished
        assert_true(sync_log.finished)
Beispiel #2
0
    def test_finished(self):
        sync_log = SyncLogFactory.create()

        # Create repo without existing log so sync is unfinished.
        repo = RepositoryFactory.create()
        project_sync_log = ProjectSyncLogFactory.create(
            sync_log=sync_log, project__repositories=[repo]
        )

        # Sync isn't finished until all repos are finished.
        assert not sync_log.finished

        repo_log = RepositorySyncLogFactory.create(
            repository=repo,
            project_sync_log=project_sync_log,
            start_time=aware_datetime(2015, 1, 1),
            end_time=None,
        )
        del sync_log.finished
        assert not sync_log.finished

        repo_log.end_time = aware_datetime(2015, 1, 2)
        repo_log.save()

        del sync_log.finished
        assert sync_log.finished
Beispiel #3
0
    def setUp(self):
        super().setUp()
        self.db_project = ProjectFactory.create()
        self.repository = self.db_project.repositories.all()[0]
        self.sync_log = SyncLogFactory.create()

        self.mock_pull_source_repo_changes = self.patch(
            "pontoon.sync.tasks.pull_source_repo_changes", return_value=True)
        self.mock_project_needs_sync = self.patch_object(
            Project,
            "needs_sync",
            new_callable=PropertyMock,
            return_value=True)

        self.mock_sync_translations = self.patch(
            "pontoon.sync.tasks.sync_translations")

        self.mock_update_originals = self.patch(
            "pontoon.sync.tasks.update_originals",
            return_value=[[], [], [], []])

        self.mock_source_directory_path = self.patch(
            "pontoon.sync.vcs.models.VCSProject.source_directory_path",
            return_value=self.repository.checkout_path,
        )
Beispiel #4
0
    def test_end_time_unfinished(self):
        """If a job is unfinished, it's end_time is None."""
        sync_log = SyncLogFactory.create()

        # Create repo without existing log so sync is unfinished.
        repo = RepositoryFactory.create()
        ProjectSyncLogFactory.create(sync_log=sync_log, project__repositories=[repo])

        assert sync_log.end_time is None
Beispiel #5
0
    def test_end_time_unfinished(self):
        """If a job is unfinished, it's end_time is None."""
        sync_log = SyncLogFactory.create()

        # Create repo without existing log so sync is unfinished.
        repo = RepositoryFactory.create()
        ProjectSyncLogFactory.create(sync_log=sync_log, project__repositories=[repo])

        assert_is_none(sync_log.end_time)
Beispiel #6
0
    def test_end_time(self):
        """
        Return the latest end time among repo sync logs for this log.
        """
        sync_log = SyncLogFactory.create()
        RepositorySyncLogFactory.create(project_sync_log__sync_log=sync_log,
                                        end_time=aware_datetime(2015, 1, 1))
        RepositorySyncLogFactory.create(project_sync_log__sync_log=sync_log,
                                        end_time=aware_datetime(2015, 1, 2))

        assert_equal(sync_log.end_time, aware_datetime(2015, 1, 2))
Beispiel #7
0
    def test_end_time_skipped(self):
        """Include skipped repos in finding the latest end time."""
        sync_log = SyncLogFactory.create()
        RepositorySyncLogFactory.create(project_sync_log__sync_log=sync_log,
                                        end_time=aware_datetime(2015, 1, 1))
        ProjectSyncLogFactory.create(sync_log=sync_log, skipped=True,
                                     skipped_end_time=aware_datetime(2015, 1, 2))
        ProjectSyncLogFactory.create(sync_log=sync_log, skipped=True,
                                     skipped_end_time=aware_datetime(2015, 1, 4))

        assert_equal(sync_log.end_time, aware_datetime(2015, 1, 4))
Beispiel #8
0
    def test_end_time(self):
        """
        Return the latest end time among repo sync logs for this log.
        """
        sync_log = SyncLogFactory.create()
        RepositorySyncLogFactory.create(project_sync_log__sync_log=sync_log,
                                        end_time=aware_datetime(2015, 1, 1))
        RepositorySyncLogFactory.create(project_sync_log__sync_log=sync_log,
                                        end_time=aware_datetime(2015, 1, 2))

        assert_equal(sync_log.end_time, aware_datetime(2015, 1, 2))
Beispiel #9
0
    def test_end_time_skipped(self):
        """Include skipped repos in finding the latest end time."""
        sync_log = SyncLogFactory.create()
        RepositorySyncLogFactory.create(project_sync_log__sync_log=sync_log,
                                        end_time=aware_datetime(2015, 1, 1))
        ProjectSyncLogFactory.create(sync_log=sync_log, skipped=True,
                                     skipped_end_time=aware_datetime(2015, 1, 2))
        ProjectSyncLogFactory.create(sync_log=sync_log, skipped=True,
                                     skipped_end_time=aware_datetime(2015, 1, 4))

        assert_equal(sync_log.end_time, aware_datetime(2015, 1, 4))
Beispiel #10
0
    def setUp(self):
        super(SyncProjectTests, self).setUp()
        self.db_project = ProjectFactory.create()
        self.sync_log = SyncLogFactory.create()

        self.mock_pull_changes = self.patch(
            'pontoon.sync.tasks.pull_changes', return_value=True)
        self.mock_project_needs_sync = self.patch_object(
            Project, 'needs_sync', new_callable=PropertyMock, return_value=True)
        self.mock_sync_project_repo = self.patch('pontoon.sync.tasks.sync_project_repo')

        self.mock_perform_sync_project = self.patch('pontoon.sync.tasks.perform_sync_project', return_value=[[], []])
Beispiel #11
0
    def setUp(self):
        super(SyncProjectTests, self).setUp()
        self.db_project = ProjectFactory.create()
        self.sync_log = SyncLogFactory.create()

        self.mock_pull_changes = self.patch(
            'pontoon.sync.tasks.pull_changes', return_value=True)
        self.mock_project_needs_sync = self.patch_object(
            Project, 'needs_sync', new_callable=PropertyMock, return_value=True)
        self.mock_sync_project_repo = self.patch('pontoon.sync.tasks.sync_project_repo')

        self.mock_perform_sync_project = self.patch('pontoon.sync.tasks.perform_sync_project')
Beispiel #12
0
    def setUp(self):
        super(SyncProjectTests, self).setUp()
        self.db_project = ProjectFactory.create()
        self.repository = self.db_project.repositories.all()[0]
        self.sync_log = SyncLogFactory.create()

        self.mock_pull_changes = self.patch(
            'pontoon.sync.tasks.pull_changes', return_value=(True, {}))
        self.mock_project_needs_sync = self.patch_object(
            Project, 'needs_sync', new_callable=PropertyMock, return_value=True)
        self.mock_sync_project_repo = self.patch('pontoon.sync.tasks.sync_project_repo')

        self.mock_perform_sync_project = self.patch('pontoon.sync.tasks.perform_sync_project', return_value=[[], [], []])

        self.mock_source_directory_path = self.patch('pontoon.sync.vcs.models.VCSProject.source_directory_path',
                                                            return_value=self.repository.checkout_path)
Beispiel #13
0
    def setUp(self):
        super(SyncProjectTests, self).setUp()
        self.db_project = ProjectFactory.create()
        self.repository = self.db_project.repositories.all()[0]
        self.sync_log = SyncLogFactory.create()

        self.mock_pull_changes = self.patch('pontoon.sync.tasks.pull_changes',
                                            return_value=(True, {}))
        self.mock_project_needs_sync = self.patch_object(
            Project,
            'needs_sync',
            new_callable=PropertyMock,
            return_value=True)
        self.mock_sync_project_repo = self.patch(
            'pontoon.sync.tasks.sync_project_repo')

        self.mock_perform_sync_project = self.patch(
            'pontoon.sync.tasks.perform_sync_project', return_value=[[], []])

        self.mock_source_directory_path = self.patch(
            'pontoon.sync.vcs.models.VCSProject.source_directory_path',
            return_value=self.repository.checkout_path)