2929from ConfigParser import ConfigParser
3030import codecs
3131
32+
3233class PaymentDevicesManager (object ):
3334
3435 def __init__ (self , cfg ):
@@ -157,7 +158,7 @@ def canPayout(self):
157158 return None
158159 if self .mode == "canPayout" :
159160 # commands already sent
160- if not None in self .canPayoutAmounts :
161+ if None not in self .canPayoutAmounts :
161162 # all devices sent replies
162163 canPayoutAmounts = self .canPayoutAmounts
163164 self .canPayoutAmounts = None # invalidate cache
@@ -232,7 +233,7 @@ def _updatePayinAmounts(self):
232233 """
233234 for d in self .devices :
234235 maximum = self .maximumPayin - self .getCurrentAmount ()
235- if d .getCurrentAmount () != None :
236+ if d .getCurrentAmount () is not None :
236237 maximum += d .getCurrentAmount ()
237238 d .updateAcceptValue (maximum )
238239
@@ -242,7 +243,7 @@ def getCurrentAmount(self):
242243 """
243244 totalSum = self .finishedAmount
244245 for d in self .devices :
245- if d .getCurrentAmount () != None :
246+ if d .getCurrentAmount () is not None :
246247 totalSum += d .getCurrentAmount ()
247248 return totalSum
248249
@@ -346,6 +347,7 @@ def getFinalAmount(self):
346347 self .mode = "idle"
347348 return ret
348349
350+
349351class PaymentDevicesManagerTest (unittest .TestCase ):
350352 """ Test PaymentDevicesManager
351353 """
@@ -355,7 +357,7 @@ def test_canPayout_with_one_random_datapoint_on_example_server(self):
355357 """
356358 # probably hacky, should be improved
357359 cfg = ConfigParser ()
358- cfg .readfp (codecs .open ('./FabLabKasse/config.ini.example ' , 'r' , 'utf8' ))
360+ cfg .readfp (codecs .open ('./FabLabKasse/config.defaults.ini ' , 'r' , 'utf8' ))
359361
360362 for _ in range (0 , 9 ):
361363 history = []
@@ -406,6 +408,7 @@ def myRandInt(n): # 0 ... n, with a finite >0 probability for both endpoints
406408 self .assertTrue (requested - canRemain <= paidOut <= requested , msg = msg )
407409 self .assertTrue (paidOut >= 0 , msg = msg )
408410
411+
409412def demo ():
410413 """Simple demonstration using two exampleServer devices"""
411414 # TODO this code seems to be broken, maybe adapt code from unittest or discard
0 commit comments