Set up test case for the final discovery test.
Test not run yet, and code is missing, marked with ####HERE####
1 parent 447832a commit fd4e868bce59ad515b46731a2c0306a3846fc264
@David Whale David Whale authored on 25 May 2016
Showing 2 changed files
View
1
■■■■
src/energenie/Registry.py
Discovery.__init__(self, registry, router)
self.ask_fn = ask
 
def unknown_device(self, address, message):
####HERE####
print("TODO: unknown device confirmed join %s" % str(address))
# if it is not a join req
# route to unhandled message handler
# if it is a join req
View
28
src/energenie/Registry_test.py
# expect a accept
registry.list()
fsk_router.list()
 
#---- HERE ----
 
def test_discovery_autojoin(self):
def XXXtest_discovery_autojoin(self):
discovery_autojoin()
 
# Poke synthetic unknown JOIN into the router and let it route to unknown handler
self.msg = OpenThings.Message(header_mfrid=Devices.MFRID_ENERGENIE,
header_productid=Devices.PRODUCTID_MIHO005,
header_sensorid=UNKNOWN_SENSOR_ID)
self.msg[OpenThings.PARAM_JOIN] = {}
##print(self.msg)
 
fsk_router.incoming_message(
(Devices.MFRID_ENERGENIE, Devices.PRODUCTID_MIHO005, UNKNOWN_SENSOR_ID), self.msg)
 
####FAIL - join detect is not written
# expect auto accept and join_ack logic to fire
##registry.list()
##fsk_router.list()
registry.list()
fsk_router.list()
 
def XXXXtest_discovery_askjoin(self):
#----- HERE -----
 
def test_discovery_askjoin(self):
def no(a,b): return False
def yes(a,b): return True
 
discovery_askjoin(no)
 
# Poke synthetic unknown JOIN into the router and let it route to unknown handler
self.msg = OpenThings.Message(header_mfrid=Devices.MFRID_ENERGENIE,
header_productid=Devices.MIHO005,
header_productid=Devices.PRODUCTID_MIHO005,
header_sensorid=UNKNOWN_SENSOR_ID)
self.msg[OpenThings.PARAM_JOIN] = {}
 
fsk_router.incoming_message(
(Devices.MFRID_ENERGENIE, Devices.PRODUCTID_MIHO005, UNKNOWN_SENSOR_ID), self.msg)
 
####FAIL - join detect is not written
# expect auto accept and join_ack logic to fire
# expect reject
##registry.list()
##fsk_router.list()
 
discovery_askjoin(no)
##discovery_askjoin(no)
 
fsk_router.incoming_message(
(Devices.MFRID_ENERGENIE, Devices.PRODUCTID_MIHO005, UNKNOWN_SENSOR_ID), self.msg)
##fsk_router.incoming_message(
## (Devices.MFRID_ENERGENIE, Devices.PRODUCTID_MIHO005, UNKNOWN_SENSOR_ID), self.msg)
 
####FAIL - join detect is not written
# expect auto accept and join_ack logic to fire
##registry.list()
##fsk_router.list()