Пример #1
0
    def test_handle_disabled_projects(self):
        """Only sync projects that aren't disabled."""
        disabled_project = ProjectFactory.create(disabled=True, repository_type='git')
        active_project = ProjectFactory.create(disabled=False, repository_type='git')
        self.command.handle_project = Mock()
        self.execute_command()

        self.command.handle_project.assert_any_call(active_project)
        assert_not_in(call(disabled_project), self.command.handle_project.mock_calls)
Пример #2
0
    def test_handle_disabled_projects(self):
        """Only sync projects that aren't disabled."""
        disabled_project = ProjectFactory.create(disabled=True)
        active_project = ProjectFactory.create(disabled=False)
        self.command.handle_project = Mock()
        self.execute_command()

        self.command.handle_project.assert_any_call(active_project)
        assert_not_in(call(disabled_project), self.command.handle_project.mock_calls)
Пример #3
0
    def test_update_db_clean_entity_translation(self):
        """
        If no changes have been made to the database entity or the
        translation, do not bother updating them in the database.
        """
        self.update_main_db_entity()

        # TODO: It'd be nice if we didn't rely on internal changeset
        # attributes to check this, but not vital.
        assert_not_in(self.main_db_entity, self.changeset.entities_to_update)
        assert_not_in(self.main_db_translation, self.changeset.translations_to_update)
Пример #4
0
    def test_update_db_clean_entity_translation(self):
        """
        If no changes have been made to the database entity or the
        translation, do not bother updating them in the database.
        """
        self.update_main_db_entity()

        # TODO: It'd be nice if we didn't rely on internal changeset
        # attributes to check this, but not vital.
        assert_not_in(self.main_db_entity, self.changeset.entities_to_update)
        assert_not_in(self.main_db_translation, self.changeset.translations_to_update)
Пример #5
0
    def test_handle_project_slugs(self):
        """
        If project slugs are passed to Command.handle, only sync projects
        matching those slugs.
        """
        ignore_project, handle_project = ProjectFactory.create_batch(2)
        self.command.handle_project = Mock()
        self.execute_command(handle_project.slug)

        self.command.handle_project.assert_called_with(handle_project)
        assert_not_in(call(ignore_project), self.command.handle_project.mock_calls)
Пример #6
0
    def test_handle_project_slugs(self):
        """
        If project slugs are passed to Command.handle, only sync projects
        matching those slugs.
        """
        ignore_project, handle_project = ProjectFactory.create_batch(2,
            repository_type='git'
        )
        self.command.handle_project = Mock()
        self.execute_command(handle_project.slug)

        self.command.handle_project.assert_called_with(handle_project)
        assert_not_in(call(ignore_project), self.command.handle_project.mock_calls)
Пример #7
0
    def test_update_db_unapprove_clean(self):
        """
        If translations that are set to be unapproved were already unapproved,
        don't bother updating them.
        """
        self.main_db_translation.approved = False
        self.main_db_translation.approved_date = None
        self.main_db_translation.approved_user = None
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = 'New Translated String'

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_not_in(self.main_db_translation, self.changeset.translations_to_update)
Пример #8
0
    def test_update_db_unapprove_clean(self):
        """
        If translations that are set to be unapproved were already unapproved,
        don't bother updating them.
        """
        self.main_db_translation.approved = False
        self.main_db_translation.approved_date = None
        self.main_db_translation.approved_user = None
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = 'New Translated String'

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_not_in(self.main_db_translation, self.changeset.translations_to_update)
Пример #9
0
    def test_basic(self):
        """
        Call update_stats on all resources available in the current
        locale.
        """
        with patch('pontoon.sync.core.update_stats') as update_stats:
            update_project_stats(self.db_project, self.vcs_project, self.changeset)

            update_stats.assert_any_call(self.main_db_resource, self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource, self.translated_locale)
            assert_not_in(
                call(self.missing_db_resource, self.translated_locale),
                update_stats.mock_calls
            )
Пример #10
0
    def test_update_stats(self):
        """
        Call update_stats on all resources available in the current
        locale.
        """
        with patch.object(sync_projects, 'update_stats') as update_stats:
            self.command.update_stats(self.db_project, self.vcs_project, self.changeset)

            update_stats.assert_any_call(self.main_db_resource, self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource, self.translated_locale)
            assert_not_in(
                call(self.missing_db_resource, self.translated_locale),
                update_stats.mock_calls
            )
Пример #11
0
    def test_update_stats(self):
        """
        Call update_stats on all resources available in the current
        locale.
        """
        with patch.object(sync_projects, 'update_stats') as update_stats:
            self.command.update_stats(self.db_project, self.vcs_project, self.changeset)

            update_stats.assert_any_call(self.main_db_resource, self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource, self.translated_locale)
            assert_not_in(
                call(self.missing_db_resource, self.translated_locale),
                update_stats.mock_calls
            )
Пример #12
0
    def test_basic(self):
        """
        Call update_stats on all resources available in the current
        locale.
        """
        with patch('pontoon.sync.core.update_stats') as update_stats:
            update_project_stats(self.db_project, self.vcs_project,
                                 self.changeset, self.translated_locale)

            update_stats.assert_any_call(self.main_db_resource, self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource, self.translated_locale)
            assert_not_in(
                call(self.missing_db_resource, self.translated_locale),
                update_stats.mock_calls
            )
Пример #13
0
    def test_extra_locales(self):
        """
        Only update stats for active locales, even if the inactive
        locale has a resource.
        """
        with patch('pontoon.sync.core.update_stats') as update_stats:
            update_project_stats(self.db_project, self.vcs_project,
                                 self.changeset, self.translated_locale)

            update_stats.assert_any_call(self.main_db_resource,
                                         self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource,
                                         self.translated_locale)
            assert_not_in(call(self.main_db_resource, self.inactive_locale),
                          update_stats.mock_calls)
            assert_not_in(call(self.other_db_resource, self.inactive_locale),
                          update_stats.mock_calls)
Пример #14
0
    def test_extra_locales(self):
        """
        Only update stats for active locales, even if the inactive
        locale has a resource.
        """
        with patch('pontoon.sync.core.update_stats') as update_stats:
            update_project_stats(self.db_project, self.vcs_project, self.changeset)

            update_stats.assert_any_call(self.main_db_resource, self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource, self.translated_locale)
            assert_not_in(
                call(self.main_db_resource, self.inactive_locale),
                update_stats.mock_calls
            )
            assert_not_in(
                call(self.other_db_resource, self.inactive_locale),
                update_stats.mock_calls
            )
Пример #15
0
    def test_update_stats_extra_locales(self):
        """
        Only update stats for active locales, even if the inactive
        locale has a resource.
        """
        with patch.object(sync_projects, 'update_stats') as update_stats:
            self.command.update_stats(self.db_project, self.vcs_project, self.changeset)

            update_stats.assert_any_call(self.main_db_resource, self.translated_locale)
            update_stats.assert_any_call(self.other_db_resource, self.translated_locale)
            assert_not_in(
                call(self.main_db_resource, self.inactive_locale),
                update_stats.mock_calls
            )
            assert_not_in(
                call(self.other_db_resource, self.inactive_locale),
                update_stats.mock_calls
            )