Skip to content

Commit

Permalink
Adding unit test case for complex row (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed May 1, 2018
1 parent 6640e2e commit e7ef1e3
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

class TranslatorTest(unittest.TestCase):

def setUp(self):
self.maxDiff = None

def test_translates_row_with_simple_phrase(self):
row = {
'index': 162,
Expand Down Expand Up @@ -82,5 +85,44 @@ def test_translates_row_with_comment(self):
,\tI8\tL12\tNoCAP\tNoPAREN\tI-COMMENT
seeds\tI9\tL12\tNoCAP\tNoPAREN\tI-COMMENT
scraped\tI10\tL12\tNoCAP\tNoPAREN\tI-COMMENT
""".strip(),
translator.translate_row(row).strip())

def test_translates_complex_row(self):
row = {
'index':
0,
'input': ('1 1/4 cups cooked and pureed fresh butternut squash, '
'or 1 10-ounce package frozen squash, defrosted'),
'name':
'butternut squash',
'qty':
1.25,
'range_end':
0.0,
'unit':
'cup',
'comment': ('cooked and pureed fresh, or 1 10-ounce package '
'frozen squash, defrosted'),
}

self.assertMultiLineEqual("""
1$1/4\tI1\tL20\tNoCAP\tNoPAREN\tB-QTY
cups\tI2\tL20\tNoCAP\tNoPAREN\tB-UNIT
cooked\tI3\tL20\tNoCAP\tNoPAREN\tB-COMMENT
and\tI4\tL20\tNoCAP\tNoPAREN\tI-COMMENT
pureed\tI5\tL20\tNoCAP\tNoPAREN\tI-COMMENT
fresh\tI6\tL20\tNoCAP\tNoPAREN\tI-COMMENT
butternut\tI7\tL20\tNoCAP\tNoPAREN\tB-NAME
squash\tI8\tL20\tNoCAP\tNoPAREN\tI-NAME
,\tI9\tL20\tNoCAP\tNoPAREN\tOTHER
or\tI10\tL20\tNoCAP\tNoPAREN\tI-COMMENT
1\tI11\tL20\tNoCAP\tNoPAREN\tI-COMMENT
10-ounce\tI12\tL20\tNoCAP\tNoPAREN\tI-COMMENT
package\tI13\tL20\tNoCAP\tNoPAREN\tI-COMMENT
frozen\tI14\tL20\tNoCAP\tNoPAREN\tI-COMMENT
squash\tI15\tL20\tNoCAP\tNoPAREN\tB-NAME
,\tI16\tL20\tNoCAP\tNoPAREN\tOTHER
defrosted\tI17\tL20\tNoCAP\tNoPAREN\tI-COMMENT
""".strip(),
translator.translate_row(row).strip())

0 comments on commit e7ef1e3

Please sign in to comment.