From a7961f28f30d74e9663f640756ca29d5c96282ca Mon Sep 17 00:00:00 2001 From: lwalter86 Date: Thu, 21 Apr 2016 16:21:48 +0200 Subject: [PATCH] issue #12 --- py_my_key/readers.py | 5 ++++- tests/test_py_my_key.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/py_my_key/readers.py b/py_my_key/readers.py index a3e7919..a0fbef1 100644 --- a/py_my_key/readers.py +++ b/py_my_key/readers.py @@ -31,6 +31,7 @@ class BaseReader(Base): def initialize(self): self.tts = 0.1 + self.wfc = 10 # waiting for a card timeout def _read(self): logger.info("BaseReader _read") @@ -54,7 +55,7 @@ def reading(self): dt_prev = dt time.sleep(self.tts) - def read(self, card_id_master, td_limit=datetime.timedelta(seconds=10)): + def read(self, card_id_master, td_limit=datetime.timedelta(seconds=self.ttc)): dt_start_waiting_card = datetime.datetime.utcnow() while True: dt = datetime.datetime.utcnow() @@ -72,6 +73,7 @@ class NxppyReader(BaseReader): def initialize(self): self.mifare = nxppy.Mifare() self.tts = 0.1 + self.wfc = 10 def _read(self): data = '' @@ -88,6 +90,7 @@ def _read(self): class TestReader(BaseReader): def initialize(self): self.tts = 0 + self.wfc = 0 def initialize_data(self, lst_data): self._lst_data = lst_data diff --git a/tests/test_py_my_key.py b/tests/test_py_my_key.py index 41f6f83..6bed3ab 100644 --- a/tests/test_py_my_key.py +++ b/tests/test_py_my_key.py @@ -35,8 +35,10 @@ def tearDown(self): def test_000_something(self): my_app = App(self.db_uri, self.hardware_name, self.reader_name) + my_app.hw.lock.time_opened = 0 my_app.create_reader() # init reader = my_app.reader(self.reader_id) + reader.initialize() reader.initialize_data(['A0000000', 'A0000001', 'A0000000', 'A0000001', @@ -47,12 +49,12 @@ def test_000_something(self): # First card (A0000000) is set as master card_id = reader._read() my_app._process(reader, card_id) - #time.sleep(1) + # time.sleep(1) # A0000001 try to enter but is not allowed card_id = reader._read() my_app._process(reader, card_id) - #my_app._hw.black_btn.press() + # my_app._hw.black_btn.press() # Allow A0000001 to enter (by A0000000) my_app.hw.black_btn.press() @@ -68,4 +70,4 @@ def test_000_something(self): card_id = reader._read() my_app._process(reader, card_id) - assert_equal(my_app.session.query(Event).count(), 5) \ No newline at end of file + assert_equal(my_app.session.query(Event).count(), 5)