async def test_get_companions(self) -> None: with tempfile.NamedTemporaryFile() as f: companion_manager = DirectCompanionManager( logger=mock.MagicMock(), state_file_path=f.name ) companion = CompanionInfo( udid="asdasda", host="foohost", port=123, is_local=False ) with open(f.name, "w") as f: json.dump(json_data_companions([companion]), f) companions = companion_manager._load() read_companion: CompanionInfo = companions[0] self.assertEqual(companion, read_companion)
async def test_remove_companion_with_udid(self) -> None: with tempfile.NamedTemporaryFile() as f: companion_manager = DirectCompanionManager(logger=mock.MagicMock(), state_file_path=f.name) companion = CompanionInfo(udid="asdasda", host="foohost", port=123, is_local=False) with open(f.name, "w") as f: json.dump(json_data_companions([companion]), f) companion_manager.remove_companion( Address(host=companion.host, port=companion.port)) companions = companion_manager._load() self.assertEqual(companions, [])