Esempio n. 1
0
    def test_handle_entities(self):
        """Call handle_entity on all matching Entity and VCSEntity pairs."""
        vcs_entities = {
            'match': VCSEntityFactory(),
            'no_db_match': VCSEntityFactory()
        }
        db_entities = {
            'match': EntityFactory(),
            'no_vcs_match': EntityFactory()
        }

        with patch('pontoon.sync.core.get_vcs_entities', return_value=vcs_entities), \
             patch('pontoon.sync.core.get_db_entities', return_value=db_entities), \
             patch('pontoon.sync.core.handle_entity') as mock_handle_entity:
            sync_project(self.db_project)

        mock_handle_entity.assert_has_calls([
            call(ANY, self.db_project, 'match', db_entities['match'],
                 vcs_entities['match']),
            call(ANY, self.db_project, 'no_vcs_match',
                 db_entities['no_vcs_match'], None),
            call(ANY, self.db_project, 'no_db_match', None,
                 vcs_entities['no_db_match']),
        ],
                                            any_order=True)
Esempio n. 2
0
    def test_has_translation_for(self):
        """
        Return True if a translation exists for the given locale, even
        if the translation is empty/falsey.
        """
        empty_translation = VCSTranslationFactory(strings={})
        full_translation = VCSTranslationFactory(strings={None: 'TRANSLATED'})
        entity = VCSEntityFactory()
        entity.translations = {'empty': empty_translation, 'full': full_translation}

        assert_false(entity.has_translation_for('missing'))
        assert_true(entity.has_translation_for('empty'))
        assert_true(entity.has_translation_for('full'))
Esempio n. 3
0
    def test_has_translation_for(self):
        """
        Return True if a translation exists for the given locale, even
        if the translation is empty/falsey.
        """
        empty_translation = VCSTranslationFactory(strings={})
        full_translation = VCSTranslationFactory(strings={None: "TRANSLATED"})
        entity = VCSEntityFactory()
        entity.translations = {"empty": empty_translation, "full": full_translation}

        assert_false(entity.has_translation_for("missing"))
        assert_true(entity.has_translation_for("empty"))
        assert_true(entity.has_translation_for("full"))
Esempio n. 4
0
    def test_has_translation_for(self):
        """
        Return True if a translation exists for the given locale, even
        if the translation is empty/falsey.
        """
        empty_translation = VCSTranslationFactory(strings={})
        full_translation = VCSTranslationFactory(strings={None: 'TRANSLATED'})
        entity = VCSEntityFactory()
        entity.translations = {'empty': empty_translation, 'full': full_translation}

        assert_false(entity.has_translation_for('missing'))
        assert_true(entity.has_translation_for('empty'))
        assert_true(entity.has_translation_for('full'))