コード例 #1
0
ファイル: test_views.py プロジェクト: vedantc98/pontoon
    def test_best_quality_entry(self):
        """
        Translation memory should return results entries aggregated by
        translation string.
        """
        new_locale = LocaleFactory.create()
        memory_entry = TranslationMemoryFactory.create(source="aaa",
                                                       target="ccc",
                                                       locale=new_locale)
        TranslationMemoryFactory.create(source="aaa",
                                        target="ddd",
                                        locale=new_locale)
        TranslationMemoryFactory.create(source="bbb",
                                        target="ccc",
                                        locale=new_locale)

        response = self.client.get('/translation-memory/', {
            'text': 'aaa',
            'pk': memory_entry.entity.pk,
            'locale': new_locale.code
        })
        assert_json(response, [{
            "count": 1,
            "source": "aaa",
            "quality": 100.0,
            "target": "ddd"
        }])
コード例 #2
0
ファイル: test_views.py プロジェクト: vedantc98/pontoon
    def test_minimal_quality(self):
        """
        View shouldn't return any entries if 70% of quality at minimum.
        """
        # Generate some random entries that shouldn't be similar
        TranslationMemoryFactory.create_batch(5)

        response = self.client.get('/translation-memory/', {
            'text': 'no match',
            'pk': 2,
            'locale': 'en-GB'
        })
        assert_code(response, 200)
        assert_equal(response.content, '[]')
コード例 #3
0
ファイル: test_views.py プロジェクト: MikkCZ/pontoon
    def test_minimal_quality(self):
        """
        View shouldn't return any entries if 70% of quality at minimum.
        """
        # Generate some random entries that shouldn't be similar
        TranslationMemoryFactory.create_batch(5)

        response = self.client.get('/translation-memory/', {
            'text': 'no match',
            'pk': 2,
            'locale': 'en-GB'
        })
        assert_code(response, 200)
        assert_equal(response.content, '[]')
コード例 #4
0
ファイル: test_views.py プロジェクト: MikkCZ/pontoon
    def test_best_quality_entry(self):
        """
        Translation memory should return results entries aggregated by
        translation string.
        """
        new_locale = LocaleFactory.create()
        memory_entry = TranslationMemoryFactory.create(source="aaa", target="ccc", locale=new_locale)
        TranslationMemoryFactory.create(source="aaa", target="ddd", locale=new_locale)
        TranslationMemoryFactory.create(source="bbb", target="ccc", locale=new_locale)

        response = self.client.get('/translation-memory/', {
            'text': 'aaa',
            'pk': memory_entry.entity.pk,
            'locale': new_locale.code
        })
        assert_json(response, [{"count": 1, "source": "aaa", "quality": 100.0, "target": "ddd"}])
コード例 #5
0
ファイル: test_views.py プロジェクト: vedantc98/pontoon
    def test_translation_counts(self):
        """
        Translation memory should aggregate identical translations strings
        from the different entities and count up their occurrences.
        """
        new_locale = LocaleFactory.create()
        memory_entry = TranslationMemoryFactory.create(source="aaaa",
                                                       target="ccc",
                                                       locale=new_locale)
        TranslationMemoryFactory.create(source="abaa",
                                        target="ccc",
                                        locale=new_locale)
        TranslationMemoryFactory.create(source="aaab",
                                        target="ccc",
                                        locale=new_locale)
        TranslationMemoryFactory.create(source="aaab",
                                        target="ccc",
                                        locale=new_locale)

        response = self.client.get(
            '/translation-memory/', {
                'text': 'aaaa',
                'pk': memory_entry.entity.pk,
                'locale': memory_entry.locale.code
            })

        result = response.json()
        src_string = result[0].pop('source')

        assert_true(src_string in ('abaa', 'aaab', 'aaab'))
        assert_equal(result, [{
            u'count': 3,
            u'quality': 75.0,
            u'target': u'ccc',
        }])
コード例 #6
0
ファイル: test_views.py プロジェクト: MikkCZ/pontoon
    def test_translation_counts(self):
        """
        Translation memory should aggregate identical translations strings
        from the different entities and count up their occurrences.
        """
        new_locale = LocaleFactory.create()
        memory_entry = TranslationMemoryFactory.create(source="aaaa", target="ccc", locale=new_locale)
        TranslationMemoryFactory.create(source="abaa", target="ccc", locale=new_locale)
        TranslationMemoryFactory.create(source="aaab", target="ccc", locale=new_locale)
        TranslationMemoryFactory.create(source="aaab", target="ccc", locale=new_locale)

        response = self.client.get('/translation-memory/', {
            'text': 'aaaa',
            'pk': memory_entry.entity.pk,
            'locale': memory_entry.locale.code
        })

        result = response.json()
        src_string = result[0].pop('source')

        assert_true(src_string in ('abaa', 'aaab', 'aaab'))
        assert_equal(
            result,
            [{
                u'count': 3,
                u'quality': 75.0,
                u'target': u'ccc',
            }]
        )
コード例 #7
0
ファイル: test_views.py プロジェクト: callkalpa/pontoon
 def test_exclude_entity(self):
     """
     Exclude entity from results to avoid false positive results.
     """
     memory_entry = TranslationMemoryFactory.create(source="Pontoon Intro")
     response = self.client.get('/translation-memory/', {
         'text': 'Pontoon Intro',
         'pk': memory_entry.entity.pk,
         'locale': memory_entry.locale.code
     })
     assert_code(response, 200)
     assert_equal(response.content, '[]')