Skip to content

Commit

Permalink
Implement Glossary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan4253 committed Nov 28, 2023
1 parent 2d07ba9 commit d0163df
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
27 changes: 25 additions & 2 deletions test/Util/Glossary_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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です"
Empty file removed test/assets/SampleCorrection.csv
Empty file.
1 change: 1 addition & 0 deletions test/assets/SampleCorrections.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
na,hna
1 change: 1 addition & 0 deletions test/assets/SampleNames.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ジョナサン,Jonathan

0 comments on commit d0163df

Please sign in to comment.