def test_convert_phrase_complains_about_missing_translation(): randomPhrase = str(random.randint(0, 1000)) expected_error = 'Phrase "{}" needs to have a "Translation".'.format( randomPhrase) with pytest.raises(RuntimeError, match=expected_error): _convert_phrase({"Phrase": randomPhrase})
def test_includes_alternative_translations(self): result = _convert_phrase(self.fakePhrase).in_source_language assert self.fakePhrase["Alternative translations"][0] in result assert self.fakePhrase["Alternative translations"][1] in result
def test_alternative_translations_are_optional(self): del self.fakePhrase["Alternative translations"] assert len(_convert_phrase(self.fakePhrase).in_source_language) == 1
def test_includes_translation(self): assert _convert_phrase( self.fakePhrase ).in_source_language[0] == self.fakePhrase["Translation"]
def test_alternative_versions_are_optional(self): del self.fakePhrase["Alternative versions"] assert len(_convert_phrase(self.fakePhrase).in_target_language) == 1
def test_includes_alternative_versions(self): result = _convert_phrase(self.fakePhrase).in_target_language assert self.fakePhrase["Alternative versions"][0] in result assert self.fakePhrase["Alternative versions"][1] in result
def test_includes_main_version(self): assert _convert_phrase( self.fakePhrase).in_target_language[0] == self.fakePhrase["Phrase"]
def test_returns_a_phrase_object(self): assert type(_convert_phrase(self.fakePhrase)) == Phrase