diff --git a/test/Util/Glossary_test.py b/test/Util/Glossary_test.py index 8e3ff70..d0fae7b 100644 --- a/test/Util/Glossary_test.py +++ b/test/Util/Glossary_test.py @@ -2,5 +2,28 @@ import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -import unittest -from TenshiTranslator.Util.Glossary import Glossary \ No newline at end of file +import pytest +from TenshiTranslator.Util.Glossary import Glossary + +def test_Constructor(): + glossary = Glossary("test/assets/SampleNames.csv", "test/assets/SampleCorrections.csv") + names = glossary.names + corrections = glossary.corrections + + assert names == {'ジョナサン': 'Jonathan'} + assert corrections == {'na': 'hna'} + + with pytest.raises(SystemExit) as excinfo: + glossary = Glossary("test/assets/SampleNames.csv", "lol.csv") + + assert excinfo.value.code == 1 + +def test_Replacements(): + glossary = Glossary("test/assets/SampleNames.csv", "test/assets/SampleCorrections.csv") + line = "こんにちは、私の名前はジョナサンです" + + line = glossary.replaceNames(line) + assert line == "こんにちは、私の名前はJonathanです" + + line = glossary.applyCorrections(line) + assert line == "こんにちは、私の名前はJohnathanです" \ No newline at end of file diff --git a/test/assets/SampleCorrection.csv b/test/assets/SampleCorrection.csv deleted file mode 100644 index e69de29..0000000 diff --git a/test/assets/SampleCorrections.csv b/test/assets/SampleCorrections.csv new file mode 100644 index 0000000..dc62f8a --- /dev/null +++ b/test/assets/SampleCorrections.csv @@ -0,0 +1 @@ +na,hna \ No newline at end of file diff --git a/test/assets/SampleNames.csv b/test/assets/SampleNames.csv index e69de29..8da1b62 100644 --- a/test/assets/SampleNames.csv +++ b/test/assets/SampleNames.csv @@ -0,0 +1 @@ +ジョナサン,Jonathan