Skip to content

Commit

Permalink
Merge pull request #32 from NabuCasa/dev
Browse files Browse the repository at this point in the history
Release 0.7
  • Loading branch information
pvizeli committed Mar 15, 2019
2 parents 7122453 + e3d5bfe commit a55a287
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions hass_nabucasa/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

DISPATCH_REMOTE_CONNECT = "remote_connect"
DISPATCH_REMOTE_DISCONNECT = "remote_disconnect"
DISPATCH_REMOTE_BACKEND_UP = "remote_backend_up"
DISPATCH_REMOTE_BACKEND_DOWN = "remote_backend_down"

SERVERS = {
"production": {
Expand Down
3 changes: 3 additions & 0 deletions hass_nabucasa/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ async def load_backend(self) -> None:
self._snitun_server = server

await self._snitun.start()
self.cloud.client.dispatcher_message(const.DISPATCH_REMOTE_BACKEND_UP)

# Connect to remote is autostart enabled
if self.cloud.client.remote_autostart:
Expand All @@ -201,6 +202,8 @@ async def close_backend(self) -> None:
self._instance_domain = None
self._snitun_server = None

self.cloud.client.dispatcher_message(const.DISPATCH_REMOTE_BACKEND_DOWN)

async def handle_connection_requests(self, caller_ip: str) -> None:
"""Handle connection requests."""
if not self._snitun:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

VERSION = "0.6"
VERSION = "0.7"

setup(
name="hass-nabucasa",
Expand Down
16 changes: 13 additions & 3 deletions tests/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
"""Test remote sni handler."""
import asyncio
from unittest.mock import patch, MagicMock, Mock
from datetime import timedelta
from unittest.mock import MagicMock, Mock, patch

import pytest

from hass_nabucasa.const import (
DISPATCH_REMOTE_BACKEND_DOWN,
DISPATCH_REMOTE_BACKEND_UP,
DISPATCH_REMOTE_CONNECT,
DISPATCH_REMOTE_DISCONNECT,
)
from hass_nabucasa.remote import RemoteUI
from hass_nabucasa.utils import utcnow
from hass_nabucasa.const import DISPATCH_REMOTE_CONNECT, DISPATCH_REMOTE_DISCONNECT

from .common import mock_coro, MockAcme, MockSnitun
from .common import MockAcme, MockSnitun, mock_coro


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -93,6 +98,9 @@ async def test_load_backend_exists_cert(
assert remote._acme_task
assert remote._reconnect_task

assert cloud_mock.client.mock_dispatcher[0][0] == DISPATCH_REMOTE_BACKEND_UP
assert cloud_mock.client.mock_dispatcher[1][0] == DISPATCH_REMOTE_CONNECT


async def test_load_backend_not_exists_cert(
cloud_mock, acme_mock, mock_cognito, aioclient_mock, snitun_mock
Expand Down Expand Up @@ -198,6 +206,8 @@ async def test_load_and_unload_backend(
assert not remote._acme_task
assert not remote._reconnect_task

assert cloud_mock.client.mock_dispatcher[-1][0] == DISPATCH_REMOTE_BACKEND_DOWN


async def test_load_backend_exists_wrong_cert(
cloud_mock, acme_mock, mock_cognito, aioclient_mock, snitun_mock
Expand Down

0 comments on commit a55a287

Please sign in to comment.