Skip to content

Commit

Permalink
Call pn53x device test methods explicitely.
Browse files Browse the repository at this point in the history
  • Loading branch information
nehpetsde committed Mar 22, 2017
1 parent 401fdb5 commit 786da0b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/base_clf_pn53x.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,12 @@ def pn53x_test_sense_tta_target_is_dep(self, device):
assert target.sdd_res == HEX('0416C6C2D73881')
return target

def test_sense_tta_unsupported_bitrate(self, device):
def pn53x_test_sense_tta_unsupported_bitrate(self, device):
with pytest.raises(ValueError) as excinfo:
device.sense_tta(nfc.clf.RemoteTarget('100A'))
assert str(excinfo.value) == "unsupported bitrate 100A"

@pytest.mark.parametrize("uid, initiator_data", [
('01020304', '01020304'),
('01020304050607', '8801020304050607'),
('01020304050607080910', '880102038804050607080910'),
])
def test_sense_tta_send_with_uid(self, device, uid, initiator_data):
def pn53x_test_sense_tta_send_with_uid(self, device, uid, initiator_data):
device.chipset.transport.read.side_effect = [
ACK(), RSP('4B 00'), # InListPassiveTarget
ACK(), self.reg_rsp('26'), # ReadRegister
Expand All @@ -537,7 +532,7 @@ def test_sense_tta_send_with_uid(self, device, uid, initiator_data):
CMD('06 6339'), # ReadRegister
]]

def test_sense_tta_rid_response_error(self, device):
def pn53x_test_sense_tta_rid_response_error(self, device):
device.chipset.transport.read.side_effect = [
ACK(), RSP('4B 00'), # InListPassiveTarget
ACK(), self.reg_rsp('93'), # ReadRegister
Expand All @@ -546,7 +541,7 @@ def test_sense_tta_rid_response_error(self, device):
]
assert device.sense_tta(nfc.clf.RemoteTarget('106A')) is None

def test_sense_tta_tt1_response_timeout(self, device):
def pn53x_test_sense_tta_tt1_response_timeout(self, device):
device.chipset.transport.read.side_effect = [
ACK(), RSP('4B 00'), # InListPassiveTarget
ACK(), self.reg_rsp('93'), # ReadRegister
Expand All @@ -563,7 +558,12 @@ def pn53x_test_sense_ttb_no_target_found(self, device):
CMD('4A 010300'), # InListPassiveTarget
]]

def test_sense_ttf_no_target_found(self, device):
def pn53x_test_sense_ttb_unsupported_bitrate(self, device):
with pytest.raises(ValueError) as excinfo:
device.sense_ttb(nfc.clf.RemoteTarget('100B'))
assert str(excinfo.value) == "unsupported bitrate 100B"

def pn53x_test_sense_ttf_no_target_found(self, device):
device.chipset.transport.read.side_effect = [
ACK(), self.reg_rsp('03'), # ReadRegister
ACK(), RSP('4B 00'), # InListPassiveTarget
Expand All @@ -574,7 +574,7 @@ def test_sense_ttf_no_target_found(self, device):
CMD('4A 010100ffff0100'), # InListPassiveTarget
]]

def test_sense_ttf_target_found(self, device):
def pn53x_test_sense_ttf_target_found(self, device):
sensf_res = '01 0102030405060708 F1F2F3F4F5F6F7F8 AABB'
device.chipset.transport.read.side_effect = [
ACK(), self.reg_rsp('03'), # ReadRegister
Expand All @@ -589,7 +589,7 @@ def test_sense_ttf_target_found(self, device):
CMD('4A 010100ffff0100'), # InListPassiveTarget
]]

def test_sense_ttf_more_rf_on_time(self, device):
def pn53x_test_sense_ttf_more_rf_on_time(self, device):
device.chipset.transport.read.side_effect = [
ACK(), self.reg_rsp('00'), # ReadRegister
ACK(), RSP('33'), # RFConfiguration
Expand All @@ -602,7 +602,7 @@ def test_sense_ttf_more_rf_on_time(self, device):
CMD('4A 010100ffff0100'), # InListPassiveTarget
]]

def test_sense_ttf_unsupported_bitrate(self, device):
def pn53x_test_sense_ttf_unsupported_bitrate(self, device):
with pytest.raises(ValueError) as excinfo:
device.sense_ttf(nfc.clf.RemoteTarget('100F'))
assert str(excinfo.value) == "unsupported bitrate 100F"
Expand Down
29 changes: 29 additions & 0 deletions tests/test_clf_pn531.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,40 @@ def test_sense_tta_target_tt2_cascade(self, device, sdd, sdd_res):
CMD('08 63037f'), # WriteRegister
]]

def test_sense_tta_unsupported_bitrate(self, device):
self.pn53x_test_sense_tta_unsupported_bitrate(device)

@pytest.mark.parametrize("uid, initiator_data", [
('01020304', '01020304'),
('01020304050607', '8801020304050607'),
('01020304050607080910', '880102038804050607080910'),
])
def test_sense_tta_send_with_uid(self, device, uid, initiator_data):
self.pn53x_test_sense_tta_send_with_uid(device, uid, initiator_data)

def test_sense_tta_rid_response_error(self, device):
self.pn53x_test_sense_tta_rid_response_error(device)

def test_sense_tta_tt1_response_timeout(self, device):
self.pn53x_test_sense_tta_tt1_response_timeout(device)

def test_sense_ttb_is_not_supported(self, device):
with pytest.raises(nfc.clf.UnsupportedTargetError) as excinfo:
device.sense_ttb(nfc.clf.RemoteTarget('106B'))
assert "does not support sense for Type B Target" in str(excinfo.value)

def test_sense_ttf_no_target_found(self, device):
self.pn53x_test_sense_ttf_no_target_found(device)

def test_sense_ttf_target_found(self, device):
self.pn53x_test_sense_ttf_target_found(device)

def test_sense_ttf_more_rf_on_time(self, device):
self.pn53x_test_sense_ttf_more_rf_on_time(device)

def test_sense_ttf_unsupported_bitrate(self, device):
self.pn53x_test_sense_ttf_unsupported_bitrate(device)

def test_sense_dep_no_target_found(self, device):
self.pn53x_test_sense_dep_no_target_found(device)

Expand Down
32 changes: 32 additions & 0 deletions tests/test_clf_pn532.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,41 @@ def test_sense_tta_target_is_dep(self, device):
CMD('4A 0100'), # InListPassiveTarget
]]

def test_sense_tta_unsupported_bitrate(self, device):
self.pn53x_test_sense_tta_unsupported_bitrate(device)

@pytest.mark.parametrize("uid, initiator_data", [
('01020304', '01020304'),
('01020304050607', '8801020304050607'),
('01020304050607080910', '880102038804050607080910'),
])
def test_sense_tta_send_with_uid(self, device, uid, initiator_data):
self.pn53x_test_sense_tta_send_with_uid(device, uid, initiator_data)

def test_sense_tta_rid_response_error(self, device):
self.pn53x_test_sense_tta_rid_response_error(device)

def test_sense_tta_tt1_response_timeout(self, device):
self.pn53x_test_sense_tta_tt1_response_timeout(device)

def test_sense_ttb_no_target_found(self, device):
self.pn53x_test_sense_ttb_no_target_found(device)

def test_sense_ttb_unsupported_bitrate(self, device):
self.pn53x_test_sense_ttb_unsupported_bitrate(device)

def test_sense_ttf_no_target_found(self, device):
self.pn53x_test_sense_ttf_no_target_found(device)

def test_sense_ttf_target_found(self, device):
self.pn53x_test_sense_ttf_target_found(device)

def test_sense_ttf_more_rf_on_time(self, device):
self.pn53x_test_sense_ttf_more_rf_on_time(device)

def test_sense_ttf_unsupported_bitrate(self, device):
self.pn53x_test_sense_ttf_unsupported_bitrate(device)

def test_sense_dep_no_target_found(self, device):
self.pn53x_test_sense_dep_no_target_found(device)

Expand Down
32 changes: 32 additions & 0 deletions tests/test_clf_pn533.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,41 @@ def test_sense_tta_target_is_dep(self, device):
CMD('4A 0100'), # InListPassiveTarget
]]

def test_sense_tta_unsupported_bitrate(self, device):
self.pn53x_test_sense_tta_unsupported_bitrate(device)

@pytest.mark.parametrize("uid, initiator_data", [
('01020304', '01020304'),
('01020304050607', '8801020304050607'),
('01020304050607080910', '880102038804050607080910'),
])
def test_sense_tta_send_with_uid(self, device, uid, initiator_data):
self.pn53x_test_sense_tta_send_with_uid(device, uid, initiator_data)

def test_sense_tta_rid_response_error(self, device):
self.pn53x_test_sense_tta_rid_response_error(device)

def test_sense_tta_tt1_response_timeout(self, device):
self.pn53x_test_sense_tta_tt1_response_timeout(device)

def test_sense_ttb_no_target_found(self, device):
self.pn53x_test_sense_ttb_no_target_found(device)

def test_sense_ttb_unsupported_bitrate(self, device):
self.pn53x_test_sense_ttb_unsupported_bitrate(device)

def test_sense_ttf_no_target_found(self, device):
self.pn53x_test_sense_ttf_no_target_found(device)

def test_sense_ttf_target_found(self, device):
self.pn53x_test_sense_ttf_target_found(device)

def test_sense_ttf_more_rf_on_time(self, device):
self.pn53x_test_sense_ttf_more_rf_on_time(device)

def test_sense_ttf_unsupported_bitrate(self, device):
self.pn53x_test_sense_ttf_unsupported_bitrate(device)

def test_sense_dep_no_target_found(self, device):
self.pn53x_test_sense_dep_no_target_found(device)

Expand Down

0 comments on commit 786da0b

Please sign in to comment.