glossary test: added description test
This commit is contained in:
parent
91a7541581
commit
86295c6492
@ -13,6 +13,7 @@ class TestGlossary(unittest.TestCase):
|
|||||||
# Prepare a temporary YAML file with valid content
|
# Prepare a temporary YAML file with valid content
|
||||||
with tempfile.NamedTemporaryFile('w', delete=False, suffix=glossary_suffix) as yaml_file:
|
with tempfile.NamedTemporaryFile('w', delete=False, suffix=glossary_suffix) as yaml_file:
|
||||||
yaml_file.write("Name: Sample\n"
|
yaml_file.write("Name: Sample\n"
|
||||||
|
"Description: A brief description\n"
|
||||||
"ID: '123'\n"
|
"ID: '123'\n"
|
||||||
"SourceLang: en\n"
|
"SourceLang: en\n"
|
||||||
"TargetLang: es\n"
|
"TargetLang: es\n"
|
||||||
@ -24,6 +25,8 @@ class TestGlossary(unittest.TestCase):
|
|||||||
|
|
||||||
glossary = Glossary.from_file(yaml_file_path)
|
glossary = Glossary.from_file(yaml_file_path)
|
||||||
self.assertEqual(glossary.name, "Sample")
|
self.assertEqual(glossary.name, "Sample")
|
||||||
|
self.assertEqual(glossary.desc, "A brief description")
|
||||||
|
self.assertEqual(glossary.ID, "123")
|
||||||
self.assertEqual(glossary.source_lang, "en")
|
self.assertEqual(glossary.source_lang, "en")
|
||||||
self.assertEqual(glossary.target_lang, "es")
|
self.assertEqual(glossary.target_lang, "es")
|
||||||
self.assertEqual(glossary.entries, {"hello": "hola", "goodbye": "adiós", "yes": "sí"})
|
self.assertEqual(glossary.entries, {"hello": "hola", "goodbye": "adiós", "yes": "sí"})
|
||||||
@ -31,7 +34,12 @@ class TestGlossary(unittest.TestCase):
|
|||||||
|
|
||||||
def test_to_file_writes_yaml(self) -> None:
|
def test_to_file_writes_yaml(self) -> None:
|
||||||
# Create glossary instance
|
# Create glossary instance
|
||||||
glossary = Glossary(name="Test", source_lang="en", target_lang="fr", entries={"yes": "oui"})
|
glossary = Glossary(name="Test",
|
||||||
|
desc="Test description",
|
||||||
|
ID="666",
|
||||||
|
source_lang="en",
|
||||||
|
target_lang="fr",
|
||||||
|
entries={"yes": "oui"})
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile('w', delete=False, suffix=glossary_suffix) as tmp_file:
|
with tempfile.NamedTemporaryFile('w', delete=False, suffix=glossary_suffix) as tmp_file:
|
||||||
file_path = Path(tmp_file.name)
|
file_path = Path(tmp_file.name)
|
||||||
@ -41,6 +49,8 @@ class TestGlossary(unittest.TestCase):
|
|||||||
content = file.read()
|
content = file.read()
|
||||||
|
|
||||||
self.assertIn("Name: Test", content)
|
self.assertIn("Name: Test", content)
|
||||||
|
self.assertIn("Description: Test description", content)
|
||||||
|
self.assertIn("ID: '666'", content)
|
||||||
self.assertIn("SourceLang: en", content)
|
self.assertIn("SourceLang: en", content)
|
||||||
self.assertIn("TargetLang: fr", content)
|
self.assertIn("TargetLang: fr", content)
|
||||||
self.assertIn("Entries", content)
|
self.assertIn("Entries", content)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user