コード例 #1
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]
        )
コード例 #2
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])
コード例 #3
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}
        )
コード例 #4
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]
        )
コード例 #5
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}
        )
コード例 #6
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)
        )
コード例 #7
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)
        )
コード例 #8
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]
        )
コード例 #9
0
ファイル: test_models.py プロジェクト: m8ttyB/pontoon
 def setUp(self):
     self.user0, self.user1 = UserFactory.create_batch(2)
コード例 #10
0
ファイル: test_models.py プロジェクト: yfdyh000/pontoon
 def setUp(self):
     self.user0, self.user1 = UserFactory.create_batch(2)