Esempio n. 1
0
 def test_exists(self):
     unit = Unit.objects.all()[0]
     request = HttpRequest()
     request.user = self.user
     # Create fake fulltext entry
     other = unit.translation.unit_set.exclude(pk=unit.pk)[0]
     other.source = unit.source
     other.target = 'Preklad'
     other.state = STATE_TRANSLATED
     other.save()
     update_fulltext(
         pk=other.pk,
         source=force_text(unit.source),
         context=force_text(unit.context),
         location=force_text(unit.location),
         target=force_text(other.target),
         comment='',
         language=force_text(unit.translation.language.code),
     )
     # Perform lookup
     machine = WeblateTranslation()
     results = machine.translate(
         unit.translation.language.code,
         unit.get_source_plurals()[0],
         unit,
         request,
     )
     self.assertNotEqual(results, [])
Esempio n. 2
0
 def test_exists(self):
     unit = Unit.objects.filter(translation__language_code="cs")[0]
     # Create fake fulltext entry
     other = unit.translation.unit_set.exclude(pk=unit.pk)[0]
     other.source = unit.source
     other.target = 'Preklad'
     other.state = STATE_TRANSLATED
     other.save()
     update_fulltext(
         None,
         pk=other.pk,
         source=force_str(unit.source),
         context=force_str(unit.context),
         location=force_str(unit.location),
         target=force_str(other.target),
         note='',
         language=force_str(unit.translation.language.code),
     )
     # Perform lookup
     machine = WeblateTranslation()
     results = machine.translate(
         unit.translation.language.code,
         unit.get_source_plurals()[0],
         unit,
         self.user,
     )
     self.assertNotEqual(results, [])
Esempio n. 3
0
 def test_exists(self):
     unit = Unit.objects.all()[0]
     request = HttpRequest()
     request.user = self.user
     # Create fake fulltext entry
     other = unit.translation.unit_set.exclude(pk=unit.pk)[0]
     other.source = unit.source
     other.target = 'Preklad'
     other.state = STATE_TRANSLATED
     other.save()
     update_fulltext(
         pk=other.pk,
         source=force_text(unit.source),
         context=force_text(unit.context),
         location=force_text(unit.location),
         target=force_text(other.target),
         comment='',
         language=force_text(unit.translation.language.code),
     )
     # Perform lookup
     machine = WeblateTranslation()
     results = machine.translate(
         unit.translation.language.code,
         unit.get_source_plurals()[0],
         unit,
         request,
     )
     self.assertNotEqual(results, [])