Ejemplo n.º 1
0
    def test_status(self):
        repo = RepositoryFactory.create()
        project_sync_log = ProjectSyncLogFactory.create(
            project__repositories=[repo], skipped=False
        )

        # Repos aren't finished, status should be in-progress.
        assert project_sync_log.status == ProjectSyncLog.IN_PROGRESS

        # Once repo is finished, status should be synced.
        RepositorySyncLogFactory.create(
            repository=repo,
            project_sync_log=project_sync_log,
            start_time=aware_datetime(2015, 1, 1),
            end_time=aware_datetime(2015, 1, 1, 1),
        )

        del project_sync_log.finished
        del project_sync_log.status
        assert project_sync_log.status == ProjectSyncLog.SYNCED

        # Skipped projects are just "skipped".
        skipped_log = ProjectSyncLogFactory.create(
            project__repositories=[repo],
            skipped=True,
        )

        assert skipped_log.status == ProjectSyncLog.SKIPPED
Ejemplo n.º 2
0
    def test_status(self):
        repo = RepositoryFactory.create()
        project_sync_log = ProjectSyncLogFactory.create(
            project__repositories=[repo],
            skipped=False
        )

        # Repos aren't finished, status should be in-progress.
        assert_equal(project_sync_log.status, ProjectSyncLog.IN_PROGRESS)

        # Once repo is finished, status should be synced.
        RepositorySyncLogFactory.create(
            repository=repo,
            project_sync_log=project_sync_log,
            start_time=aware_datetime(2015, 1, 1),
            end_time=aware_datetime(2015, 1, 1, 1),
        )

        del project_sync_log.finished
        del project_sync_log.status
        assert_equal(project_sync_log.status, ProjectSyncLog.SYNCED)

        # Skipped projects are just "skipped".
        skipped_log = ProjectSyncLogFactory.create(
            project__repositories=[repo],
            skipped=True,
        )

        assert_equal(skipped_log.status, ProjectSyncLog.SKIPPED)
Ejemplo n.º 3
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
Ejemplo n.º 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_is_none(sync_log.end_time)
Ejemplo n.º 5
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))
Ejemplo n.º 6
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))
Ejemplo n.º 7
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
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    def setUp(self):
        super(SyncProjectRepoTests, self).setUp()
        self.project_sync_log = ProjectSyncLogFactory.create()

        self.mock_pull_changes = self.patch(
            'pontoon.sync.tasks.pull_changes', return_value=True)
        self.mock_commit_changes = self.patch('pontoon.sync.tasks.commit_changes')
        self.mock_repo_checkout_path = self.patch_object(
            Repository, 'checkout_path', new_callable=PropertyMock,
            return_value=FAKE_CHECKOUT_PATH)
Ejemplo n.º 10
0
    def setUp(self):
        super(SyncProjectRepoTests, self).setUp()
        self.project_sync_log = ProjectSyncLogFactory.create()

        self.mock_pull_changes = self.patch(
            'pontoon.sync.tasks.pull_changes', return_value=True)
        self.mock_commit_changes = self.patch('pontoon.sync.tasks.commit_changes')
        self.mock_repo_checkout_path = self.patch_object(
            Repository, 'checkout_path', new_callable=PropertyMock,
            return_value=FAKE_CHECKOUT_PATH)
Ejemplo n.º 11
0
 def test_end_time_skipped(self):
     """
     If a sync is skipped, it's end_time is self.skipped_end_time.
     """
     repo = RepositoryFactory.create()
     project_sync_log = ProjectSyncLogFactory.create(
         project__repositories=[repo],
         skipped=True,
         skipped_end_time=aware_datetime(2015, 1, 1),
     )
     assert_equal(project_sync_log.end_time, aware_datetime(2015, 1, 1))
Ejemplo n.º 12
0
 def test_end_time_skipped(self):
     """
     If a sync is skipped, it's end_time is self.skipped_end_time.
     """
     repo = RepositoryFactory.create()
     project_sync_log = ProjectSyncLogFactory.create(
         project__repositories=[repo],
         skipped=True,
         skipped_end_time=aware_datetime(2015, 1, 1),
     )
     assert_equal(project_sync_log.end_time, aware_datetime(2015, 1, 1))
Ejemplo n.º 13
0
    def test_end_time(self):
        """
        Return the latest end time among repo sync logs for this log.
        """
        project = ProjectFactory.create(repositories=[])
        source_repo, repo1, repo2 = RepositoryFactory.create_batch(3, project=project)
        project_sync_log = ProjectSyncLogFactory.create(project=project)

        RepositorySyncLogFactory.create(project_sync_log=project_sync_log,
                                        repository=repo1,
                                        end_time=aware_datetime(2015, 1, 1))

        assert_equal(project_sync_log.end_time, aware_datetime(2015, 1, 1))
Ejemplo n.º 14
0
    def test_end_time(self):
        """
        Return the latest end time among repo sync logs for this log.
        """
        project = ProjectFactory.create(repositories=[])
        source_repo, repo1, repo2 = RepositoryFactory.create_batch(3, project=project)
        project_sync_log = ProjectSyncLogFactory.create(project=project)

        RepositorySyncLogFactory.create(project_sync_log=project_sync_log,
                                        repository=repo1,
                                        end_time=aware_datetime(2015, 1, 1))

        assert_equal(project_sync_log.end_time, aware_datetime(2015, 1, 1))
Ejemplo n.º 15
0
    def setUp(self):
        super(SyncTranslationsTests, self).setUp()
        self.project_sync_log = ProjectSyncLogFactory.create()

        self.mock_pull_changes = self.patch(
            'pontoon.sync.tasks.pull_changes', return_value=[True, {}])
        self.mock_commit_changes = self.patch('pontoon.sync.tasks.commit_changes')
        self.mock_repo_checkout_path = self.patch_object(
            Repository, 'checkout_path', new_callable=PropertyMock,
            return_value=FAKE_CHECKOUT_PATH)
        self.mock_changes = {
            'update_db': [],
            'obsolete_db': [],
            'create_db': []
        }
Ejemplo n.º 16
0
    def setUp(self):
        super(SyncTranslationsTests, self).setUp()
        self.project_sync_log = ProjectSyncLogFactory.create()

        self.mock_pull_changes = self.patch("pontoon.sync.tasks.pull_changes",
                                            return_value=[True, {}])
        self.mock_commit_changes = self.patch(
            "pontoon.sync.tasks.commit_changes")
        self.mock_pretranslate = self.patch("pontoon.sync.tasks.pretranslate")
        self.mock_repo_checkout_path = self.patch_object(
            Repository,
            "checkout_path",
            new_callable=PropertyMock,
            return_value=FAKE_CHECKOUT_PATH,
        )
Ejemplo n.º 17
0
    def test_finished(self):
        repo = RepositoryFactory.create()
        project_sync_log = ProjectSyncLogFactory.create(
            project__repositories=[repo])

        # Sync isn't finished until all repos are finished.
        assert_false(project_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)
        assert_false(project_sync_log.finished)

        repo_log.end_time = aware_datetime(2015, 1, 2)
        repo_log.save()
        assert_true(project_sync_log.finished)
Ejemplo n.º 18
0
    def test_finished(self):
        repo = RepositoryFactory.create()
        project_sync_log = ProjectSyncLogFactory.create(project__repositories=[repo])

        # Sync isn't finished until all repos are finished.
        assert_false(project_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
        )
        assert_false(project_sync_log.finished)

        repo_log.end_time = aware_datetime(2015, 1, 2)
        repo_log.save()
        assert_true(project_sync_log.finished)
Ejemplo n.º 19
0
    def setUp(self):
        super(SyncTranslationsTests, self).setUp()
        self.project_sync_log = ProjectSyncLogFactory.create()

        self.mock_pull_changes = self.patch('pontoon.sync.tasks.pull_changes',
                                            return_value=[True, {}])
        self.mock_commit_changes = self.patch(
            'pontoon.sync.tasks.commit_changes')
        self.mock_repo_checkout_path = self.patch_object(
            Repository,
            'checkout_path',
            new_callable=PropertyMock,
            return_value=FAKE_CHECKOUT_PATH)
        self.mock_changes = {
            'update_db': [],
            'obsolete_db': [],
            'create_db': []
        }
Ejemplo n.º 20
0
 def test_end_time_unfinished(self):
     """If a sync is unfinished, it's end_time is None."""
     repo = RepositoryFactory.create()
     project_sync_log = ProjectSyncLogFactory.create(
         project__repositories=[repo])
     assert_is_none(project_sync_log.end_time)
Ejemplo n.º 21
0
 def test_finished_skipped(self):
     """A skipped log is considered finished."""
     skipped_log = ProjectSyncLogFactory.create(skipped=True)
     assert_true(skipped_log.finished)
Ejemplo n.º 22
0
 def test_end_time_unfinished(self):
     """If a sync is unfinished, it's end_time is None."""
     repo = RepositoryFactory.create()
     project_sync_log = ProjectSyncLogFactory.create(project__repositories=[repo])
     assert_is_none(project_sync_log.end_time)
Ejemplo n.º 23
0
 def test_finished_skipped(self):
     """A skipped log is considered finished."""
     skipped_log = ProjectSyncLogFactory.create(skipped=True)
     assert_true(skipped_log.finished)