Skip to content

Commit

Permalink
issue #12
Browse files Browse the repository at this point in the history
  • Loading branch information
lwalter86 committed Apr 21, 2016
1 parent 117eceb commit a7961f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion py_my_key/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -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 = ''
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions tests/test_py_my_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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()
Expand All @@ -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)
assert_equal(my_app.session.query(Event).count(), 5)

0 comments on commit a7961f2

Please sign in to comment.