Skip to content

Commit

Permalink
Add test_listen_dep_not_activated
Browse files Browse the repository at this point in the history
  • Loading branch information
nehpetsde committed Mar 21, 2017
1 parent 3bc3b5d commit 32bdfaf
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 20 deletions.
20 changes: 13 additions & 7 deletions tests/base_clf_pn53x.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,6 @@ def pn53x_test_listen_tta_not_activated(self, device):
target.sel_res = HEX("00")
target.sdd_res = HEX("08010203")
assert device.listen_tta(target, 1.0) is None
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63013f'), # WriteRegister
CMD('8c 0144000102030000 0102030405060708'
' 090a0b0c0d0e0f10 1100010203040506'
' 0700000000'), # TgInitAsTarget
ACK(),
]]

def pn53x_test_listen_ttf_not_activated(self, device):
device.chipset.transport.read.side_effect = [
Expand All @@ -558,3 +551,16 @@ def pn53x_test_listen_ttf_not_activated(self, device):
CMD('06 6337633863346335'), # ReadRegister
CMD('08 633100'), # WriteRegister
]]

def pn53x_test_listen_dep_not_activated(self, device):
device.chipset.transport.read.side_effect = [
ACK(), RSP('09 00'), # WriteRegister
ACK(), IOError(errno.ETIMEDOUT, ""), # TgInitAsTarget
]
target = nfc.clf.LocalTarget()
target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
target.sens_res = HEX("0101")
target.sel_res = HEX("40")
target.sdd_res = HEX("08010203")
target.atr_res = HEX("D501 d0d1d2d3d4d5d6d7d8d9 0000000800")
assert device.listen_dep(target, 0.001) is None
27 changes: 14 additions & 13 deletions tests/test_clf_pn531.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,7 @@ def test_sense_dep_no_target_found(self, device):
self.pn53x_test_sense_dep_no_target_found(device)

def test_listen_tta_not_activated(self, device):
device.chipset.transport.read.side_effect = [
ACK(), RSP('09 00'), # WriteRegister
ACK(), IOError(errno.ETIMEDOUT, ""), # TgInitAsTarget
]
target = nfc.clf.LocalTarget('106A')
target.sens_res = HEX("4400")
target.sel_res = HEX("00")
target.sdd_res = HEX("08010203")
assert device.listen_tta(target, 1.0) is None
print(device.chipset.transport.write.mock_calls)
self.pn53x_test_listen_tta_not_activated(device)
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63013f'), # WriteRegister
CMD('8c 0144000102030000 0102030405060708'
Expand All @@ -158,10 +149,20 @@ def test_listen_tta_not_activated(self, device):
ACK(),
]]

def test_listen_ttf_not_activated(self, device):
self.pn53x_test_listen_ttf_not_activated(device)

def test_listen_ttb_not_supported(self, device):
with pytest.raises(nfc.clf.UnsupportedTargetError) as excinfo:
device.listen_ttb(nfc.clf.LocalTarget('106B'), 1.0)
assert "does not support listen as Type B Target" in str(excinfo.value)

def test_listen_ttf_not_activated(self, device):
self.pn53x_test_listen_ttf_not_activated(device)

def test_listen_dep_not_activated(self, device):
self.pn53x_test_listen_dep_not_activated(device)
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63017b6302b06303b0'), # WriteRegister
CMD('8c 0201010102034001 fe01020304050600'
' 0000000000000000 0001fe0102030405'
' 060000'), # TgInitAsTarget
ACK(),
]]
17 changes: 17 additions & 0 deletions tests/test_clf_pn532.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,13 @@ def test_sense_dep_no_target_found(self, device):

def test_listen_tta_not_activated(self, device):
self.pn53x_test_listen_tta_not_activated(device)
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63013f'), # WriteRegister
CMD('8c 0144000102030000 0102030405060708'
' 090a0b0c0d0e0f10 1100010203040506'
' 0700000000'), # TgInitAsTarget
ACK(),
]]

def test_listen_ttb_not_supported(self, device):
with pytest.raises(nfc.clf.UnsupportedTargetError) as excinfo:
Expand All @@ -491,3 +498,13 @@ def test_listen_ttb_not_supported(self, device):

def test_listen_ttf_not_activated(self, device):
self.pn53x_test_listen_ttf_not_activated(device)

def test_listen_dep_not_activated(self, device):
self.pn53x_test_listen_dep_not_activated(device)
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63017b6302b06303b0'), # WriteRegister
CMD('8c 0201010102034001 fe01020304050600'
' 0000000000000000 0001fe0102030405'
' 0600000000'), # TgInitAsTarget
ACK(),
]]
17 changes: 17 additions & 0 deletions tests/test_clf_pn533.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ def test_sense_dep_no_target_found(self, device):

def test_listen_tta_not_activated(self, device):
self.pn53x_test_listen_tta_not_activated(device)
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63013f'), # WriteRegister
CMD('8c 0144000102030000 0102030405060708'
' 090a0b0c0d0e0f10 1100010203040506'
' 0700000000'), # TgInitAsTarget
ACK(),
]]

def test_listen_ttb_not_supported(self, device):
with pytest.raises(nfc.clf.UnsupportedTargetError) as excinfo:
Expand All @@ -203,3 +210,13 @@ def test_listen_ttb_not_supported(self, device):

def test_listen_ttf_not_activated(self, device):
self.pn53x_test_listen_ttf_not_activated(device)

def test_listen_dep_not_activated(self, device):
self.pn53x_test_listen_dep_not_activated(device)
assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
CMD('08 63017b6302b06303b0'), # WriteRegister
CMD('8c 0201010102034001 fe01020304050600'
' 0000000000000000 0001fe0102030405'
' 0600000000'), # TgInitAsTarget
ACK(),
]]

0 comments on commit 32bdfaf

Please sign in to comment.