Skip to content

Commit 9b0e246

Browse files
authored
Merge pull request #2 from esecules/esecules-test1
Added more tests
2 parents c76152a + 940fb94 commit 9b0e246

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ python:
44
# command to install dependencies
55
install: "pip install -r setup/requirements.txt"
66
# command to run tests
7-
script: "cd test; python -m unittest ServerTest.ServerTest"
7+
script: "cd test; nosetests"

src/groupsplit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def main():
134134
rows = rows[1:]
135135
transactions = [{"date": datetime.strftime(datetime.strptime(r[date_col], "%m/%d/%y"), "%Y-%m-%dT%H:%M:%SZ"),
136136
"amount": -1 * Money(r[amount_col], local_currency),
137-
"desc": re.sub('\s+',' ', r[desc_col]})
137+
"desc": re.sub('\s+',' ', r[desc_col])}
138138
for r in rows if float(r[amount_col]) < 0]
139139
splits = []
140140
for t in transactions:
File renamed without changes.

test/testSplit.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import unittest
2+
import sys
3+
from money import Money
4+
sys.path.append("../src")
5+
from groupsplit import split
6+
7+
class UtilsTests(unittest.TestCase):
8+
def test_splits(self):
9+
cases = [
10+
{"amount": "1.00", "ppl": 2, "expect": ("0.50","0.00")},
11+
{"amount": "1.00", "ppl": 3, "expect": ("0.33", "0.01")},
12+
{"amount": "12.97", "ppl": 5, "expect": ("2.59", "0.02")},
13+
{"amount": "52000", "ppl": 3, "expect": ("17333.33", "0.01")},
14+
]
15+
for case in cases:
16+
expect = (Money(case['expect'][0], "CAD"), Money(case['expect'][1], "CAD"))
17+
self.assertEqual(expect, split(Money(case['amount'], "CAD"), case['ppl']))

0 commit comments

Comments
 (0)