33import subprocess
44from money import Money
55sys .path .append ("../src" )
6- from groupsplit import split
6+ from groupsplit import split , Splitwise
77
88class UtilsTests (unittest .TestCase ):
9+ def __init__ (self , * args , ** kwargs ):
10+ super (UtilsTests , self ).__init__ (* args , ** kwargs )
11+ self .api = Splitwise ()
12+
913 def test_splits (self ):
1014 cases = [
1115 {"amount" : "1.00" , "ppl" : 2 , "expect" : ("0.50" ,"0.00" )},
@@ -18,13 +22,25 @@ def test_splits(self):
1822 expect = (Money (case ['expect' ][0 ], "CAD" ), Money (case ['expect' ][1 ], "CAD" ))
1923 self .assertEqual (expect , split (Money (case ['amount' ], "CAD" ), case ['ppl' ]))
2024
25+ def test_get_id (self ):
26+ assertGreater (int (self .api .get_id ()), 0 )
27+
28+ def test_get_groups (self ):
29+ self .assertGreater (len (self .api .get_groups ()), 0 )
30+
2131class SystemTests (unittest .TestCase ):
32+ def __del__ (self ):
33+ api = Splitwise ()
34+ for expense in api .get_expenses ():
35+ api .delete_expense (expense ['id' ])
36+
2237 def test_group_of_2 (self ):
2338 proc = subprocess .Popen (['python' , '../src/groupsplit.py' , 'transactions.csv' , 'group_of_2' ,
2439 '--csv-settings=csv_settings.pkl' , '--api-client=oauth_client.pkl' ,
2540 '-y' ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
2641 stdout , stderr = proc .communicate ()
2742 self .assertEqual (stderr , '' )
43+
2844 def test_group_of_3 (self ):
2945 proc = subprocess .Popen (['python' , '../src/groupsplit.py' , 'transactions.csv' , 'group_of_3' ,
3046 '--csv-settings=csv_settings.pkl' , '--api-client=oauth_client.pkl' ,
0 commit comments