@@ -653,36 +653,36 @@ async def node_join(self, event: pw_api.NodeEvent, mac: str) -> None: # type: i
653653 )
654654 )
655655
656- # @pytest.mark.asyncio
657- # async def test_stick_node_join_subscription(
658- # self, monkeypatch: pytest.MonkeyPatch
659- # ) -> None:
660- # """Testing "new_node" subscription."""
661- # mock_serial = MockSerial(None)
662- # monkeypatch.setattr(
663- # pw_connection_manager,
664- # "create_serial_connection",
665- # mock_serial.mock_connection,
666- # )
667- # monkeypatch.setattr(pw_sender, "STICK_TIME_OUT", 0.1)
668- # monkeypatch.setattr(pw_requests, "NODE_TIME_OUT", 0.5)
669- # stick = pw_stick.Stick("test_port", cache_enabled=False)
670- # await stick.connect()
671- # await stick.initialize()
672- # await stick.discover_nodes(load=False)
673- # await stick.set_accept_join_request(True)
674- # self.test_node_join = asyncio.Future()
675- # unusb_join = stick.subscribe_to_node_events(
676- # node_event_callback=self.node_join,
677- # events=(pw_api.NodeEvent.JOIN,),
678- # )
679- #
680- # # Inject node join request message
681- # mock_serial.inject_message(b"00069999999999999999", b"FFFC")
682- # mac_join_node = await self.test_node_join
683- # assert mac_join_node == "9999999999999999"
684- # unusb_join()
685- # await stick.disconnect()
656+ @pytest .mark .asyncio
657+ async def test_stick_node_join_subscription (
658+ self , monkeypatch : pytest .MonkeyPatch
659+ ) -> None :
660+ """Testing "new_node" subscription."""
661+ mock_serial = MockSerial (None )
662+ monkeypatch .setattr (
663+ pw_connection_manager ,
664+ "create_serial_connection" ,
665+ mock_serial .mock_connection ,
666+ )
667+ monkeypatch .setattr (pw_sender , "STICK_TIME_OUT" , 0.1 )
668+ monkeypatch .setattr (pw_requests , "NODE_TIME_OUT" , 0.5 )
669+ stick = pw_stick .Stick ("test_port" , cache_enabled = False )
670+ await stick .connect ()
671+ await stick .initialize ()
672+ await stick .discover_nodes (load = False )
673+ await stick .set_accept_join_request (True )
674+ self .test_node_join = asyncio .Future ()
675+ unusb_join = stick .subscribe_to_node_events (
676+ node_event_callback = self .node_join ,
677+ events = (pw_api .NodeEvent .JOIN ,),
678+ )
679+
680+ # Inject node join request message
681+ mock_serial .inject_message (b"00069999999999999999" , b"FFFC" )
682+ mac_join_node = await self .test_node_join
683+ assert mac_join_node == "9999999999999999"
684+ unusb_join ()
685+ await stick .disconnect ()
686686
687687 @pytest .mark .asyncio
688688 async def test_node_discovery (self , monkeypatch : pytest .MonkeyPatch ) -> None :
0 commit comments