29
29
from ConfigParser import ConfigParser
30
30
import codecs
31
31
32
+
32
33
class PaymentDevicesManager (object ):
33
34
34
35
def __init__ (self , cfg ):
@@ -157,7 +158,7 @@ def canPayout(self):
157
158
return None
158
159
if self .mode == "canPayout" :
159
160
# commands already sent
160
- if not None in self .canPayoutAmounts :
161
+ if None not in self .canPayoutAmounts :
161
162
# all devices sent replies
162
163
canPayoutAmounts = self .canPayoutAmounts
163
164
self .canPayoutAmounts = None # invalidate cache
@@ -232,7 +233,7 @@ def _updatePayinAmounts(self):
232
233
"""
233
234
for d in self .devices :
234
235
maximum = self .maximumPayin - self .getCurrentAmount ()
235
- if d .getCurrentAmount () != None :
236
+ if d .getCurrentAmount () is not None :
236
237
maximum += d .getCurrentAmount ()
237
238
d .updateAcceptValue (maximum )
238
239
@@ -242,7 +243,7 @@ def getCurrentAmount(self):
242
243
"""
243
244
totalSum = self .finishedAmount
244
245
for d in self .devices :
245
- if d .getCurrentAmount () != None :
246
+ if d .getCurrentAmount () is not None :
246
247
totalSum += d .getCurrentAmount ()
247
248
return totalSum
248
249
@@ -346,6 +347,7 @@ def getFinalAmount(self):
346
347
self .mode = "idle"
347
348
return ret
348
349
350
+
349
351
class PaymentDevicesManagerTest (unittest .TestCase ):
350
352
""" Test PaymentDevicesManager
351
353
"""
@@ -355,7 +357,7 @@ def test_canPayout_with_one_random_datapoint_on_example_server(self):
355
357
"""
356
358
# probably hacky, should be improved
357
359
cfg = ConfigParser ()
358
- cfg .readfp (codecs .open ('./FabLabKasse/config.ini.example ' , 'r' , 'utf8' ))
360
+ cfg .readfp (codecs .open ('./FabLabKasse/config.defaults.ini ' , 'r' , 'utf8' ))
359
361
360
362
for _ in range (0 , 9 ):
361
363
history = []
@@ -406,6 +408,7 @@ def myRandInt(n): # 0 ... n, with a finite >0 probability for both endpoints
406
408
self .assertTrue (requested - canRemain <= paidOut <= requested , msg = msg )
407
409
self .assertTrue (paidOut >= 0 , msg = msg )
408
410
411
+
409
412
def demo ():
410
413
"""Simple demonstration using two exampleServer devices"""
411
414
# TODO this code seems to be broken, maybe adapt code from unittest or discard
0 commit comments