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" }])
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 }) assert_json(response, [{ u'count': 3, u'quality': 75.0, u'source': u'abaa', u'target': u'ccc' }])
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"}])
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 }) assert_json(response, {u'translations': [{u'count': 3, u'quality': 75.0, u'source': u'abaa', u'target': u'ccc'}]})