コード例 #1
0
ファイル: test_changeset.py プロジェクト: MikkCZ/pontoon
    def test_multiple_translations(self):
        """
        If there are multiple translations to the same locale, only authors of
        the final approved version should be returned.
        """
        first_author, second_author = UserFactory.create_batch(2)

        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=first_author,
            approved=True
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=second_author,
            approved=False
        )

        self.changeset.update_vcs_entity(self.translated_locale, self.main_db_entity, MagicMock())

        self.changeset.execute_update_vcs()

        assert_equal(
            self.changeset.commit_authors_per_locale[self.translated_locale.code],
            [first_author]
        )
コード例 #2
0
ファイル: test_models.py プロジェクト: sudheesh001/pontoon
    def test_translators_group(self):
        """
        Tests if user has permission to translate locales after assigment.
        """
        user = UserFactory.create()
        [first_locale, second_locale] = LocaleFactory.create_batch(2)

        assert_equal(user.has_perm('base.can_translate_locale'), False)
        assert_equal(user.has_perm('base.can_translate_locale', first_locale),
                     False)
        assert_equal(user.has_perm('base.can_translate_locale', second_locale),
                     False)

        user.groups.add(second_locale.translators_group)

        assert_equal(user.has_perm('base.can_translate_locale'), False)
        assert_equal(user.has_perm('base.can_translate_locale', first_locale),
                     False)
        assert_equal(user.has_perm('base.can_translate_locale', second_locale),
                     True)

        user.groups.add(first_locale.translators_group)

        assert_equal(user.has_perm('base.can_translate_locale'), False)
        assert_equal(user.has_perm('base.can_translate_locale', first_locale),
                     True)
        assert_equal(user.has_perm('base.can_translate_locale', second_locale),
                     True)
コード例 #3
0
    def setUp(self):
        mock_persona_migration = patch.object(middleware.PersonaMigrationMiddleware, 'process_request', return_value=None)
        self.mock_persona_migration = mock_persona_migration.start()
        self.addCleanup(mock_persona_migration.stop)

        self.user = UserFactory.create()
        self.client.force_login(self.user)
コード例 #4
0
ファイル: test_changeset.py プロジェクト: julen/pontoon
    def test_update_db_unapprove_existing(self):
        """
        Any existing translations that don't match anything in VCS get
        unapproved, unless they were created after self.now.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = 'New Translated String'

        created_after_translation = TranslationFactory.create(
            entity=self.main_db_entity,
            approved=True,
            approved_date=aware_datetime(1970, 1, 3)
        )

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_attributes_equal(
            self.main_db_translation,
            approved=False,
            approved_user=None,
            approved_date=None
        )

        created_after_translation.refresh_from_db()
        assert_attributes_equal(
            created_after_translation,
            approved=True,
            approved_date=aware_datetime(1970, 1, 3)
        )
コード例 #5
0
 def test_update_vcs_entity_user(self):
     """Track translation authors for use in the commit message."""
     user = UserFactory.create()
     self.update_main_vcs_entity(user=user)
     assert_equal(
         self.changeset.commit_authors_per_locale['translated-locale'],
         [user])
コード例 #6
0
ファイル: test_changeset.py プロジェクト: julen/pontoon
    def test_plural_translations(self):
        """
        If entity has some plural translations and approved translations their authors
        should be included in commit message.
        """
        first_author, second_author, third_author = UserFactory.create_batch(3)

        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=first_author,
            approved=True
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=third_author,
            approved=True,
            plural_form=1
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=second_author,
            approved=False
        )

        self.changeset.update_vcs_entity(self.translated_locale, self.main_db_entity, MagicMock())

        self.changeset.execute_update_vcs()

        assert_equal(
            set(self.changeset.commit_authors_per_locale[self.translated_locale.code]),
            {first_author, third_author}
        )
コード例 #7
0
ファイル: test_changeset.py プロジェクト: MikkCZ/pontoon
    def test_plural_translations(self):
        """
        If entity has some plural translations and approved translations their authors
        should be included in commit message.
        """
        first_author, second_author, third_author = UserFactory.create_batch(3)

        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=first_author,
            approved=True
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=third_author,
            approved=True,
            plural_form=1
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=second_author,
            approved=False
        )

        self.changeset.update_vcs_entity(self.translated_locale, self.main_db_entity, MagicMock())

        self.changeset.execute_update_vcs()

        assert_equal(
            set(self.changeset.commit_authors_per_locale[self.translated_locale.code]),
            {first_author, third_author}
        )
コード例 #8
0
    def test_update_db_unapprove_fuzzy(self):
        """
        If an existing translation is fuzzy and doesn't match anything in VCS,
        unapprove and unfuzzy that translation without rejecting it.
        """
        self.main_db_translation.fuzzy = True
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        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_attributes_equal(
            self.main_db_translation,
            approved=False,
            approved_user=None,
            approved_date=None,
            rejected=False,
            fuzzy=False,
        )

        assert ActionLog.objects.filter(
            action_type="translation:unapproved",
            translation=self.main_db_translation.pk,
        ).exists()
コード例 #9
0
ファイル: test_models.py プロジェクト: dsaumyajit007/pontoon
    def test_managers_group(self):
        """
        Tests if user has permission to manage and translate locales after assigment.
        """
        user = UserFactory.create()
        [first_locale, second_locale] = LocaleFactory.create_batch(2)

        assert_equal(user.has_perm("base.can_translate_locale"), False)
        assert_equal(user.has_perm("base.can_translate_locale", first_locale), False)
        assert_equal(user.has_perm("base.can_translate_locale", second_locale), False)
        assert_equal(user.has_perm("base.can_manage_locale"), False)
        assert_equal(user.has_perm("base.can_manage_locale", first_locale), False)
        assert_equal(user.has_perm("base.can_manage_locale", second_locale), False)

        user.groups.add(second_locale.managers_group)

        assert_equal(user.has_perm("base.can_translate_locale"), False)
        assert_equal(user.has_perm("base.can_translate_locale", first_locale), False)
        assert_equal(user.has_perm("base.can_translate_locale", second_locale), True)
        assert_equal(user.has_perm("base.can_manage_locale"), False)
        assert_equal(user.has_perm("base.can_manage_locale", first_locale), False)
        assert_equal(user.has_perm("base.can_manage_locale", second_locale), True)

        user.groups.add(first_locale.managers_group)

        assert_equal(user.has_perm("base.can_translate_locale"), False)
        assert_equal(user.has_perm("base.can_translate_locale", first_locale), True)
        assert_equal(user.has_perm("base.can_translate_locale", second_locale), True)
        assert_equal(user.has_perm("base.can_manage_locale"), False)
        assert_equal(user.has_perm("base.can_manage_locale", first_locale), True)
        assert_equal(user.has_perm("base.can_manage_locale", second_locale), True)
コード例 #10
0
ファイル: test_changeset.py プロジェクト: transforlab/pontoon
    def test_update_db_unapprove_existing(self):
        """
        Any existing translations that don't match anything in VCS get
        unapproved, unless they were created after self.now.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = 'New Translated String'

        created_after_translation = TranslationFactory.create(
            entity=self.main_db_entity,
            approved=True,
            approved_date=aware_datetime(1970, 1, 3)
        )

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_attributes_equal(
            self.main_db_translation,
            approved=False,
            approved_user=None,
            approved_date=None
        )

        created_after_translation.refresh_from_db()
        assert_attributes_equal(
            created_after_translation,
            approved=True,
            approved_date=aware_datetime(1970, 1, 3)
        )
コード例 #11
0
    def test_multiple_authors(self):
        """
        Commit message should include authors from translations of separate
        entities.
        """
        first_author, second_author = UserFactory.create_batch(2)
        TranslationFactory.create(locale=self.translated_locale,
                                  entity=self.main_db_entity,
                                  user=first_author,
                                  approved=True)
        TranslationFactory.create(locale=self.translated_locale,
                                  entity=self.main_db_entity,
                                  approved=False)
        TranslationFactory.create(locale=self.translated_locale,
                                  entity=self.other_db_entity,
                                  user=second_author,
                                  approved=True)
        TranslationFactory.create(locale=self.translated_locale,
                                  entity=self.other_db_entity,
                                  approved=False)

        self.changeset.update_vcs_entity(self.translated_locale,
                                         self.main_db_entity, MagicMock())
        self.changeset.update_vcs_entity(self.translated_locale,
                                         self.other_db_entity, MagicMock())

        self.changeset.execute_update_vcs()

        assert_equal(
            self.changeset.commit_authors_per_locale[
                self.translated_locale.code], [first_author, second_author])
コード例 #12
0
ファイル: test_changeset.py プロジェクト: julen/pontoon
    def test_multiple_translations(self):
        """
        If there are multiple translations to the same locale, only authors of
        the final approved version should be returned.
        """
        first_author, second_author = UserFactory.create_batch(2)

        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=first_author,
            approved=True
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=second_author,
            approved=False
        )

        self.changeset.update_vcs_entity(self.translated_locale, self.main_db_entity, MagicMock())

        self.changeset.execute_update_vcs()

        assert_equal(
            self.changeset.commit_authors_per_locale[self.translated_locale.code],
            [first_author]
        )
コード例 #13
0
    def setUp(self):
        self.log_mock = MagicMock()
        self.user = UserFactory.create()

        mock_messages = patch('pontoon.base.adapter.messages')
        self.mock_messages = mock_messages.start()
        self.addCleanup(mock_messages.stop)

        self.adapter = PontoonSocialAdapter()
コード例 #14
0
def test_timeline_non_active_contributor(
    contributor_translations, client, mock_profile_render
):
    """Test if backend is able return events for a user without contributions."""
    nonactive_contributor = UserFactory.create()
    client.get("/contributors/{}/timeline/".format(nonactive_contributor.username))
    assert mock_profile_render.call_args[0][2]["events"] == [
        {"date": nonactive_contributor.date_joined, "type": "join"}
    ]
コード例 #15
0
ファイル: test_models.py プロジェクト: dsaumyajit007/pontoon
 def create_contributor_with_translation_counts(self, approved=0, unapproved=0, needs_work=0, **kwargs):
     """
     Helper method, creates contributor with given translations counts.
     """
     contributor = UserFactory.create()
     TranslationFactory.create_batch(approved, user=contributor, approved=True, **kwargs)
     TranslationFactory.create_batch(unapproved, user=contributor, approved=False, fuzzy=False, **kwargs)
     TranslationFactory.create_batch(needs_work, user=contributor, fuzzy=True, **kwargs)
     return contributor
コード例 #16
0
 def test_non_active_contributor(self):
     """Test if backend is able return events for a user without contributions."""
     nonactive_contributor = UserFactory.create()
     self.client.get('/contributors/{}/timeline/'.format(
         nonactive_contributor.username))
     assert_equal(self.mock_render.call_args[0][2]['events'],
                  [{
                      'date': nonactive_contributor.date_joined,
                      'type': 'join'
                  }])
コード例 #17
0
ファイル: test_models.py プロジェクト: dsaumyajit007/pontoon
    def test_users_without_translations(self):
        """
        Checks if user contributors without translations aren't returned.
        """
        active_contributor = TranslationFactory.create(user__email="*****@*****.**").user
        inactive_contributor = UserFactory.create(email="*****@*****.**")

        top_contributors = User.translators.with_translation_counts()
        assert_true(active_contributor in top_contributors)
        assert_true(inactive_contributor not in top_contributors)
コード例 #18
0
 def test_non_active_contributor(self):
     """Test if backend is able return events for a user without contributions."""
     nonactive_contributor = UserFactory.create()
     self.client.get(
         "/contributors/{}/timeline/".format(nonactive_contributor.username)
     )
     assert_equal(
         self.mock_render.call_args[0][2]["events"],
         [{"date": nonactive_contributor.date_joined, "type": "join"}],
     )
コード例 #19
0
    def test_save_extra_metadata(self):
        """
        If last_updated or last_translator is set on the latest
        translation, update the metadata for those fields.
        """
        test_input = self.generate_pofile(
            dedent("""
                msgid "Latest"
                msgstr "Latest"

                msgid "Older"
                msgstr "Older"
            """),
            revision_date='2012-01-01 00:00+0000',
            last_translator='last <*****@*****.**>'
        )
        path, resource = self.parse_string(test_input)

        latest_translation, older_translation = resource.translations
        latest_translation.last_updated = aware_datetime(2015, 1, 1, 0, 0, 0)
        latest_translation.last_translator = UserFactory(
            first_name='New',
            email='*****@*****.**'
        )
        older_translation.last_updated = aware_datetime(1970, 1, 1, 0, 0, 0)
        older_translation.last_translator = UserFactory(
            first_name='Old',
            email='*****@*****.**'
        )
        resource.save(self.locale)

        self.assert_file_content(path, self.generate_pofile(
            dedent("""
                msgid "Latest"
                msgstr "Latest"

                msgid "Older"
                msgstr "Older"
            """),
            revision_date='2015-01-01 00:00+0000',
            last_translator='New <*****@*****.**>'
        ))
コード例 #20
0
ファイル: test_views.py プロジェクト: bychek-ru/pontoon
 def test_non_active_contributor(self):
     """Test if backend is able return events for a user without contributions."""
     nonactive_contributor = UserFactory.create()
     self.client.get('/contributors/{}/timeline/'.format(nonactive_contributor.username))
     assert_equal(
         self.mock_render.call_args[0][2]['events'], [
         {
             'date': nonactive_contributor.date_joined,
             'type': 'join'
         }
     ])
コード例 #21
0
ファイル: test_models.py プロジェクト: sudheesh001/pontoon
    def test_users_without_translations(self):
        """
        Checks if user contributors without translations aren't returned.
        """
        active_contributor = TranslationFactory.create(
            user__email='*****@*****.**').user
        inactive_contributor = UserFactory.create(email='*****@*****.**')

        top_contributors = User.translators.with_translation_counts()
        assert_true(active_contributor in top_contributors)
        assert_true(inactive_contributor not in top_contributors)
コード例 #22
0
ファイル: test_core.py プロジェクト: yfdyh000/pontoon
    def test_basic(self):
        user = UserFactory.create()
        self.changeset.commit_authors_per_locale = {
            self.translated_locale.code: [user]
        }
        self.db_project.repository_for_path = Mock(
            return_value=self.repository)

        commit_changes(self.db_project, self.vcs_project, self.changeset)
        self.repository.commit.assert_called_with(
            CONTAINS(user.display_name), user,
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code))
コード例 #23
0
ファイル: test_core.py プロジェクト: rajul/pontoon
    def test_basic(self):
        user = UserFactory.create()
        self.changeset.commit_authors_per_locale = {
            self.translated_locale.code: [user]
        }
        self.db_project.repository_for_path = Mock(return_value=self.repository)

        commit_changes(self.db_project, self.vcs_project, self.changeset)
        self.repository.commit.assert_called_with(
            CONTAINS(user.display_name),
            user,
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code)
        )
コード例 #24
0
    def test_commit_changes(self):
        user = UserFactory.create()
        self.changeset.commit_authors_per_locale = {
            self.translated_locale.code: [user]
        }

        self.command.commit_changes(self.db_project, self.vcs_project, self.changeset)
        self.mock_commit_to_vcs.assert_called_with(
            'git',
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code),
            CONTAINS(user.display_name),
            user,
            'https://example.com/git'
        )
コード例 #25
0
ファイル: test_core.py プロジェクト: G33KS44n/pontoon
    def test_multiple_authors(self):
        """
        Tests if multiple authors are passed to commit message.
        """
        first_author, second_author = UserFactory.create_batch(2)
        self.changeset.commit_authors_per_locale = {
            self.translated_locale.code: [first_author, second_author]
        }
        self.db_project.repository_for_path = Mock(return_value=self.repository)

        commit_changes(self.db_project, self.vcs_project, self.changeset)
        self.repository.commit.assert_called_with(
            CONTAINS(first_author.display_name, second_author.display_name),
            first_author,
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code)
        )
コード例 #26
0
ファイル: test_core.py プロジェクト: mastizada/pontoon
    def test_author_with_multiple_contributions(self):
        """
        Tests if author with multiple contributions occurs once in commit message.
        """
        author = UserFactory.create()
        self.changeset.commit_authors_per_locale = {self.translated_locale.code: [author, author]}
        self.db_project.repository_for_path = Mock(return_value=self.repository)

        commit_changes(self.db_project, self.vcs_project, self.changeset, self.translated_locale)
        self.repository.commit.assert_called_with(
            CONTAINS(author.display_name_and_email),
            author,
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code),
        )
        commit_message = self.repository.commit.mock_calls[0][1][0]
        assert_equal(commit_message.count(author.display_name_and_email), 1)
コード例 #27
0
ファイル: test_changeset.py プロジェクト: MikkCZ/pontoon
    def test_update_db_reject_approved(self):
        """
        When a translation is submitted through VCS, reject any existing approved translations.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.rejected = False
        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_attributes_equal(
            self.main_db_translation,
            rejected=True,
        )
コード例 #28
0
    def test_update_db_reject_approved(self):
        """
        When a translation is submitted through VCS, reject any existing approved translations.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.rejected = False
        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_attributes_equal(
            self.main_db_translation,
            rejected=True,
        )
コード例 #29
0
    def test_author_with_multiple_contributions(self):
        """
        Tests if author with multiple contributions occurs once in commit message.
        """
        author = UserFactory.create()
        self.changeset.commit_authors_per_locale = {
            self.translated_locale.code: [author, author]
        }
        self.db_project.repository_for_path = Mock(
            return_value=self.repository)

        commit_changes(self.db_project, self.vcs_project, self.changeset,
                       self.translated_locale)
        self.repository.commit.assert_called_with(
            CONTAINS(author.display_name_and_email), author,
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code))
        commit_message = self.repository.commit.mock_calls[0][1][0]
        assert_equal(commit_message.count(author.display_name_and_email), 1)
コード例 #30
0
    def test_update_db_reject_approved_skip_fuzzy(self):
        """
        When a translation is submitted through VCS, reject any existing approved translations.
        Unless the same translation is submitted and only made fuzzy.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.rejected = False
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = self.main_db_translation.string
        self.main_vcs_translation.fuzzy = True

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_attributes_equal(
            self.main_db_translation, rejected=False,
        )
コード例 #31
0
ファイル: test_changeset.py プロジェクト: MikkCZ/pontoon
    def test_update_db_reject_approved_skip_fuzzy(self):
        """
        When a translation is submitted through VCS, reject any existing approved translations.
        Unless the same translation is submitted and only made fuzzy.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.rejected = False
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = self.main_db_translation.string
        self.main_vcs_translation.fuzzy = True

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_attributes_equal(
            self.main_db_translation,
            rejected=False,
        )
コード例 #32
0
ファイル: test_core.py プロジェクト: yuvrajmidha/pontoon
    def test_multiple_authors(self):
        """
        Tests if multiple authors are passed to commit message. The
        author with the most occurrences for the locale should be set as
        the commit author.
        """
        first_author, second_author = UserFactory.create_batch(2)
        self.changeset.commit_authors_per_locale = {
            self.translated_locale.code: [first_author, first_author, second_author]
        }
        self.db_project.repository_for_path = Mock(return_value=self.repository)

        commit_changes(self.db_project, self.vcs_project,
                       self.changeset, self.translated_locale)
        self.repository.commit.assert_called_with(
            CONTAINS(first_author.display_name_and_email, second_author.display_name_and_email),
            first_author,
            os.path.join(FAKE_CHECKOUT_PATH, self.translated_locale.code)
        )
コード例 #33
0
ファイル: test_changeset.py プロジェクト: zitsen/pontoon
    def test_update_db_reject_approved(self):
        """
        When a translation is submitted through VCS, reject any existing approved translations.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.rejected = False
        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_attributes_equal(
            self.main_db_translation, rejected=True,
        )

        assert ActionLog.objects.filter(
            action_type=ActionLog.ActionType.TRANSLATION_REJECTED,
            translation=self.main_db_translation.pk,
        ).exists()
コード例 #34
0
    def test_manage_project_strings(self):
        project = ProjectFactory.create(data_source='database',
                                        repositories=[])
        url = reverse('pontoon.admin.project.strings', args=(project.slug, ))

        # Test with anonymous user.
        response = self.client.get(url)
        assert_code(response, 403)

        # Test with a user that is not a superuser.
        user = UserFactory.create()
        self.client.force_login(user)

        response = self.client.get(url)
        assert_code(response, 403)

        # Test with a superuser.
        user.is_superuser = True
        user.save()

        response = self.client.get(url)
        assert_code(response, 200)
コード例 #35
0
ファイル: test_changeset.py プロジェクト: MikkCZ/pontoon
    def test_multiple_authors(self):
        """
        Commit message should include authors from translations of separate
        entities.
        """
        first_author, second_author = UserFactory.create_batch(2)
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            user=first_author,
            approved=True
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.main_db_entity,
            approved=False
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.other_db_entity,
            user=second_author,
            approved=True
        )
        TranslationFactory.create(
            locale=self.translated_locale,
            entity=self.other_db_entity,
            approved=False
        )

        self.changeset.update_vcs_entity(self.translated_locale, self.main_db_entity, MagicMock())
        self.changeset.update_vcs_entity(self.translated_locale, self.other_db_entity, MagicMock())

        self.changeset.execute_update_vcs()

        assert_equal(
            self.changeset.commit_authors_per_locale[self.translated_locale.code],
            [first_author, second_author]
        )
コード例 #36
0
ファイル: test_models.py プロジェクト: sudheesh001/pontoon
 def create_contributor_with_translation_counts(self,
                                                approved=0,
                                                unapproved=0,
                                                needs_work=0,
                                                **kwargs):
     """
     Helper method, creates contributor with given translations counts.
     """
     contributor = UserFactory.create()
     TranslationFactory.create_batch(approved,
                                     user=contributor,
                                     approved=True,
                                     **kwargs)
     TranslationFactory.create_batch(unapproved,
                                     user=contributor,
                                     approved=False,
                                     fuzzy=False,
                                     **kwargs)
     TranslationFactory.create_batch(needs_work,
                                     user=contributor,
                                     fuzzy=True,
                                     **kwargs)
     return contributor
コード例 #37
0
ファイル: test_changeset.py プロジェクト: zitsen/pontoon
    def test_update_db_unapprove_existing(self):
        """
        Any existing translations that don't match anything in VCS get
        unapproved, unless they were created after self.now.
        """
        self.main_db_translation.approved = True
        self.main_db_translation.approved_date = aware_datetime(1970, 1, 1)
        self.main_db_translation.approved_user = UserFactory.create()
        self.main_db_translation.save()
        self.main_vcs_translation.strings[None] = "New Translated String"

        created_after_translation = TranslationFactory.create(
            entity=self.main_db_entity,
            approved=True,
            approved_date=aware_datetime(1970, 1, 3),
        )

        self.update_main_db_entity()
        self.main_db_translation.refresh_from_db()
        assert_attributes_equal(
            self.main_db_translation,
            approved=False,
            approved_user=None,
            approved_date=None,
        )

        assert ActionLog.objects.filter(
            action_type=ActionLog.ActionType.TRANSLATION_REJECTED,
            translation=self.main_db_translation.pk,
        ).exists()

        created_after_translation.refresh_from_db()
        assert_attributes_equal(
            created_after_translation,
            approved=True,
            approved_date=aware_datetime(1970, 1, 3),
        )
コード例 #38
0
ファイル: test_models.py プロジェクト: yfdyh000/pontoon
 def setUp(self):
     self.user0, self.user1 = UserFactory.create_batch(2)
コード例 #39
0
 def setUp(self):
     self.user = UserFactory.create(is_superuser=True)
     self.client.force_login(self.user)
コード例 #40
0
ファイル: test_views.py プロジェクト: MikkCZ/pontoon
 def setUp(self):
     self.user = UserFactory.create()
     self.client.force_login(self.user)
コード例 #41
0
ファイル: test_views.py プロジェクト: vedantc98/pontoon
 def setUp(self):
     self.user = UserFactory.create()
     self.client.force_login(self.user)
コード例 #42
0
    def setUp(self):
        self.user = UserFactory.create()

        # Sign in but don't migrate account to fxa
        self.client.force_login(self.user)
コード例 #43
0
ファイル: test_changeset.py プロジェクト: transforlab/pontoon
 def test_update_vcs_entity_user(self):
     """Track translation authors for use in the commit message."""
     user = UserFactory.create()
     self.update_main_vcs_entity(user=user)
     assert_equal(self.changeset.commit_authors_per_locale['translated-locale'], [user])
コード例 #44
0
ファイル: test_models.py プロジェクト: m8ttyB/pontoon
 def setUp(self):
     self.user0, self.user1 = UserFactory.create_batch(2)