refactoring
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
import pytest
|
||||
import asyncio
|
||||
|
||||
from itertools import count
|
||||
from mock import patch
|
||||
from app.src.singleton import Singleton
|
||||
from app.src.async_stream import AsyncStream
|
||||
from app.src.async_stream import AsyncStream, AsyncIfcImpl
|
||||
from app.src.gen3plus.connection_g3p import ConnectionG3P
|
||||
from app.src.gen3plus.solarman_v5 import SolarmanV5
|
||||
|
||||
@pytest.fixture
|
||||
def patch_async_init():
|
||||
with patch.object(AsyncStream, '__init__') as conn:
|
||||
with patch.object(AsyncStream, '__init__', return_value= None) as conn:
|
||||
yield conn
|
||||
|
||||
@pytest.fixture
|
||||
@@ -66,18 +67,18 @@ class FakeWriter():
|
||||
|
||||
|
||||
|
||||
def test_method_calls(patch_async_init, patch_solarman_init, patch_healthy, patch_async_close, patch_solarman_close):
|
||||
spy1 = patch_async_init
|
||||
def test_method_calls(patch_solarman_init, patch_healthy, patch_async_close, patch_solarman_close):
|
||||
AsyncIfcImpl._ids = count(5)
|
||||
spy2 = patch_solarman_init
|
||||
spy3 = patch_healthy
|
||||
spy4 = patch_async_close
|
||||
spy5 = patch_solarman_close
|
||||
reader = FakeReader()
|
||||
writer = FakeWriter()
|
||||
writer = FakeWriter()
|
||||
addr = ('proxy.local', 10000)
|
||||
conn = ConnectionG3P(reader, writer, addr,
|
||||
remote_stream= None, server_side=True, client_mode=False)
|
||||
spy1.assert_called_once_with(conn, reader, writer, addr, conn._ifc)
|
||||
rstream= None, server_side=True, client_mode=False)
|
||||
assert 5 == conn._ifc.get_conn_no()
|
||||
spy2.assert_called_once_with(conn, True, False, conn._ifc)
|
||||
conn.healthy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user