def call_function(self): self.fake_path = self.fake_path / "skills" self.fake_path.mkdir(parents=True) self.create_fake_skill_meta(self.fake_path, **{ **self.fake_values, }) french = Language(self.fake_values["word3"], "") english = Language("English", "") self.fake_course = Course(french, english, [], [], None, None) self.result = _load_skill(self.fake_path / "food.yaml", self.fake_course)
def _convert_language(raw_language): """ Convert a YAML langauge description to a Language() object """ return Language( name=raw_language["Name"], code=raw_language["IETF BCP 47"], )
def test_assert_logs_correctly(self): with self.assertLogs("librelingo_json_export", level="INFO") as log: randomname1 = str(random.randint(0, 5000)) randomname2 = str(random.randint(0, 5000)) fake_course = fakes.customize( fakes.course1, target_language=Language( name=randomname1, code="" ), source_language=Language( name=randomname2, code="" ) ) _export_course_data(self.export_path, fake_course) assert log.output[0] == \ "INFO:librelingo_json_export:Writing course '{}' for '{}' speakers".format( randomname1, randomname2)
def test_load_course_output_matches_value(fs): fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures', "fake_course") fs.add_real_directory(fixture_path) result = load_course(fixture_path) assert result.target_language == Language(name="French", code="fr") assert result.source_language == Language(name="English", code="en") assert result.license == License(name='CC BY 3.0', full_name='CC BY 3.0', link='https://www.example.com/license') assert set(result.dictionary) == set([ DictionaryItem("the man", "l'homme", False), DictionaryItem("l'homme", "the man", True), DictionaryItem("the woman", "la femme", False), DictionaryItem("la femme", "the woman", True), DictionaryItem("dit", "says", True), DictionaryItem("bonjour", "hello\nhi", True), DictionaryItem("L'homme", "the man", True), DictionaryItem("says", "dit", False), DictionaryItem("hello", "bonjour\nsalut", False), DictionaryItem(word='woman', definition='femme', is_in_target_language=False), DictionaryItem(word='man', definition='homme', is_in_target_language=False), DictionaryItem(word='The', definition='la\nle', is_in_target_language=False), DictionaryItem(word='femme', definition='woman', is_in_target_language=True), DictionaryItem(word='the', definition='la\nle', is_in_target_language=False), DictionaryItem(word='La', definition='the', is_in_target_language=True), ]) assert len(result.modules) == 1 assert result.modules[0].title == "Basics" assert len(result.modules[0].skills) == 1 assert result.modules[0].skills[0] == Skill( name="Hello", id=4, image_set=["people1", "woman1", "man1"], phrases=result.modules[0].skills[0].phrases, words=result.modules[0].skills[0].words, dictionary=result.modules[0].skills[0].dictionary, ) assert result.modules[0].skills[0].phrases == [ Phrase( in_target_language=['La femme dit bonjour', 'la femme dit salut'], in_source_language=['The woman says hello', 'The woman says hi']), Phrase(in_target_language=["L'homme dit bonjour", "true"], in_source_language=['The man says hello', 'The man says hi']) ] assert result.modules[0].skills[0].words == [ Word(in_target_language=["l'homme"], in_source_language=['the man'], pictures=['man1', 'man2', 'man3']), Word(in_target_language=['la femme', 'la dame'], in_source_language=['the woman', 'the female'], pictures=None) ] assert result.special_characters == [ 'Ç', 'é', 'â', 'ê', 'î', 'ô', 'û', 'à', 'è', 'ù', 'ë', 'ï', 'ü' ]
phrases=[phrase1], image_set=["woman1", "woman2", "girl1"], dictionary=fake_dictionary, ), emptySkill, Skill( name="Mammals and birds", id=3, words=[word1], phrases=[], image_set=["just_one_image"], dictionary=fake_dictionary, ) ] language_1 = Language( name="my language", code="de", ) language_2 = Language( name="another language", code="tr", ) courseEmpty = Course(target_language=language_1, source_language=language_2, special_characters=["ä", "ß"], license=license1, modules=[], dictionary=fake_dictionary) course1 = Course(target_language=language_1,