Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require radio libs to implement probe() method for ControllerApplication class #383

Merged
merged 2 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/test_appdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ async def request(
async def permit_ncp(self, time_s=60):
pass

async def probe(self, config):
return True

with mock.patch("zigpy.ota.OTA.initialize", CoroutineMock()):
app = await App.new(ZIGPY_SCHEMA({CONF_DATABASE: database_file}))
return app
Expand Down
6 changes: 6 additions & 0 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ async def request(
async def permit_ncp(self, time_s=60):
pass

async def probe(self, config):
return True

return App({CONF_DATABASE: None})


Expand Down Expand Up @@ -99,6 +102,9 @@ async def request(
async def permit_ncp(self, time_s=60):
pass

async def probe(self, config):
return True

p1 = mock.patch.object(App, "_load_db", CoroutineMock())
p2 = mock.patch.object(App, "startup", CoroutineMock())
p3 = mock.patch.object(App, "shutdown", CoroutineMock())
Expand Down
10 changes: 9 additions & 1 deletion zigpy/application.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
import asyncio
import logging
from typing import Dict, Optional
from typing import Any, Dict, Optional

import zigpy.appdb
import zigpy.config
Expand All @@ -20,6 +20,9 @@


class ControllerApplication(zigpy.util.ListenableMixin, abc.ABC):
SCHEMA = zigpy.config.CONFIG_SCHEMA
SCHEMA_DEVICE = zigpy.config.SCHEMA_DEVICE

def __init__(self, config: Dict):
self._send_sequence = 0
self.devices: Dict[t.EUI64, zigpy.device.Device] = {}
Expand Down Expand Up @@ -395,3 +398,8 @@ def ota(self):
def pan_id(self):
"""Network PAN Id."""
return self._pan_id

@classmethod
@abc.abstractmethod
async def probe(cls, device_config: Dict[str, Any]) -> bool:
"""API/Port probe method."""