split ConnectionG3(P) in server and client class
This commit is contained in:
@@ -5,7 +5,7 @@ import asyncio
|
||||
from itertools import count
|
||||
from mock import patch
|
||||
from app.src.async_stream import AsyncStream, AsyncIfcImpl
|
||||
from app.src.gen3.connection_g3 import ConnectionG3
|
||||
from app.src.gen3.connection_g3 import ConnectionG3Server
|
||||
from app.src.gen3.talent import Talent
|
||||
|
||||
@pytest.fixture
|
||||
@@ -71,8 +71,8 @@ def test_method_calls(patch_talent_init, patch_healthy, patch_async_close, patch
|
||||
writer = FakeWriter()
|
||||
id_str = "id_string"
|
||||
addr = ('proxy.local', 10000)
|
||||
conn = ConnectionG3(reader, writer, addr,
|
||||
rstream= None, server_side=True, id_str=id_str)
|
||||
conn = ConnectionG3Server(reader, writer, addr,
|
||||
rstream= None, id_str=id_str)
|
||||
assert 5 == conn._ifc.get_conn_no()
|
||||
spy2.assert_called_once_with(conn, True, conn._ifc, id_str)
|
||||
conn.healthy()
|
||||
|
||||
@@ -6,7 +6,7 @@ from itertools import count
|
||||
from mock import patch
|
||||
from app.src.singleton import Singleton
|
||||
from app.src.async_stream import AsyncStream, AsyncIfcImpl
|
||||
from app.src.gen3plus.connection_g3p import ConnectionG3P
|
||||
from app.src.gen3plus.connection_g3p import ConnectionG3PServer
|
||||
from app.src.gen3plus.solarman_v5 import SolarmanV5
|
||||
|
||||
@pytest.fixture
|
||||
@@ -76,8 +76,8 @@ def test_method_calls(patch_solarman_init, patch_healthy, patch_async_close, pat
|
||||
reader = FakeReader()
|
||||
writer = FakeWriter()
|
||||
addr = ('proxy.local', 10000)
|
||||
conn = ConnectionG3P(reader, writer, addr,
|
||||
rstream= None, server_side=True, client_mode=False)
|
||||
conn = ConnectionG3PServer(reader, writer, addr,
|
||||
rstream= None, client_mode=False)
|
||||
assert 5 == conn._ifc.get_conn_no()
|
||||
spy2.assert_called_once_with(conn, True, False, conn._ifc)
|
||||
conn.healthy()
|
||||
|
||||
@@ -8,7 +8,7 @@ from app.src.infos import Infos
|
||||
from app.src.config import Config
|
||||
from app.src.inverter import Inverter
|
||||
from app.src.singleton import Singleton
|
||||
from app.src.gen3.connection_g3 import ConnectionG3
|
||||
from app.src.gen3.connection_g3 import ConnectionG3Server
|
||||
from app.src.gen3.inverter_g3 import InverterG3
|
||||
|
||||
from app.tests.test_modbus_tcp import patch_mqtt_err, patch_mqtt_except, test_port, test_hostname
|
||||
@@ -44,12 +44,12 @@ def module_init():
|
||||
|
||||
@pytest.fixture
|
||||
def patch_conn_init():
|
||||
with patch.object(ConnectionG3, '__init__', return_value= None) as conn:
|
||||
with patch.object(ConnectionG3Server, '__init__', return_value= None) as conn:
|
||||
yield conn
|
||||
|
||||
@pytest.fixture
|
||||
def patch_conn_close():
|
||||
with patch.object(ConnectionG3, 'close') as conn:
|
||||
with patch.object(ConnectionG3Server, 'close') as conn:
|
||||
yield conn
|
||||
|
||||
class FakeReader():
|
||||
@@ -115,7 +115,7 @@ def test_method_calls(patch_conn_init, patch_conn_close):
|
||||
inverter.r_addr = ''
|
||||
|
||||
spy1.assert_called_once()
|
||||
spy1.assert_called_once_with(reader, writer, addr, None, True)
|
||||
spy1.assert_called_once_with(reader, writer, addr, None)
|
||||
|
||||
inverter.close()
|
||||
spy2.assert_called_once()
|
||||
|
||||
@@ -8,7 +8,7 @@ from app.src.infos import Infos
|
||||
from app.src.config import Config
|
||||
from app.src.inverter import Inverter
|
||||
from app.src.singleton import Singleton
|
||||
from app.src.gen3plus.connection_g3p import ConnectionG3P
|
||||
from app.src.gen3plus.connection_g3p import ConnectionG3PServer
|
||||
from app.src.gen3plus.inverter_g3p import InverterG3P
|
||||
|
||||
from app.tests.test_modbus_tcp import patch_mqtt_err, patch_mqtt_except, test_port, test_hostname
|
||||
@@ -45,12 +45,12 @@ def module_init():
|
||||
|
||||
@pytest.fixture
|
||||
def patch_conn_init():
|
||||
with patch.object(ConnectionG3P, '__init__', return_value= None) as conn:
|
||||
with patch.object(ConnectionG3PServer, '__init__', return_value= None) as conn:
|
||||
yield conn
|
||||
|
||||
@pytest.fixture
|
||||
def patch_conn_close():
|
||||
with patch.object(ConnectionG3P, 'close') as conn:
|
||||
with patch.object(ConnectionG3PServer, 'close') as conn:
|
||||
yield conn
|
||||
|
||||
class FakeReader():
|
||||
@@ -116,7 +116,7 @@ def test_method_calls(patch_conn_init, patch_conn_close):
|
||||
inverter.r_addr = ''
|
||||
|
||||
spy1.assert_called_once()
|
||||
spy1.assert_called_once_with(reader, writer, addr, None, server_side=True, client_mode=False)
|
||||
spy1.assert_called_once_with(reader, writer, addr, None, client_mode=False)
|
||||
|
||||
inverter.close()
|
||||
spy2.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user