Skip to content

Commit 5df1caa

Browse files
committed
Fix tests
1 parent f1ba7f7 commit 5df1caa

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

tests/connection/ip/test_bare_connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
from unittest.mock import AsyncMock
23

34
import pytest
@@ -14,7 +15,9 @@ async def test_connect(mocker):
1415
protocol.is_active.return_value = True
1516

1617
create_connection_mock = AsyncMock(return_value=(None, protocol))
17-
mocker.patch.object(connection.loop, "create_connection", create_connection_mock)
18+
mocker.patch.object(
19+
asyncio.get_event_loop(), "create_connection", create_connection_mock
20+
)
1821

1922
assert connection.connected is False
2023

tests/connection/ip/test_local_ip_connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
from unittest.mock import AsyncMock
23

34
import pytest
@@ -15,7 +16,9 @@ async def test_connect(mocker):
1516
protocol.is_active.return_value = True
1617

1718
create_connection_mock = AsyncMock(return_value=(None, protocol))
18-
mocker.patch.object(connection.loop, "create_connection", create_connection_mock)
19+
mocker.patch.object(
20+
asyncio.get_event_loop(), "create_connection", create_connection_mock
21+
)
1922
connect_command_execute = mocker.patch.object(
2023
IPModuleConnectCommand, "execute", AsyncMock()
2124
)

tests/connection/ip/test_stun_ip_connection.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
from unittest.mock import AsyncMock
23

34
import pytest
@@ -17,7 +18,9 @@ async def test_connect(mocker):
1718
protocol.is_active.return_value = True
1819

1920
create_connection_mock = AsyncMock(return_value=(None, protocol))
20-
mocker.patch.object(connection.loop, "create_connection", create_connection_mock)
21+
mocker.patch.object(
22+
asyncio.get_event_loop(), "create_connection", create_connection_mock
23+
)
2124
connect_command_execute = mocker.patch.object(
2225
IPModuleConnectCommand, "execute", AsyncMock()
2326
)
@@ -74,7 +77,7 @@ async def assert_session_connect(mocker, session):
7477
"serial": "bf4c1fe4",
7578
"type": "HD77",
7679
"port": 54321,
77-
"panelSerial": "0584b067"
80+
"panelSerial": "0584b067",
7881
},
7982
{
8083
"lastUpdate": "2021-05-07T15:41:19Z",
@@ -85,7 +88,7 @@ async def assert_session_connect(mocker, session):
8588
"serial": "465e81a0",
8689
"type": "HD88",
8790
"port": 12345,
88-
"panelSerial": "0584b067"
91+
"panelSerial": "0584b067",
8992
},
9093
{
9194
"lastUpdate": "2021-05-07T15:41:19Z",
@@ -98,7 +101,7 @@ async def assert_session_connect(mocker, session):
98101
"panelSerial": "a72ed4bf",
99102
"xoraddr": "9a640069cda9b317",
100103
"API": None,
101-
"ipAddress": "0.0.0.0"
104+
"ipAddress": "0.0.0.0",
102105
},
103106
{
104107
"lastUpdate": "2021-05-07T15:41:19Z",
@@ -111,13 +114,13 @@ async def assert_session_connect(mocker, session):
111114
"panelSerial": "0584b067",
112115
"xoraddr": "c351472f48a5e1ba",
113116
"API": None,
114-
"ipAddress": "0.0.0.0"
115-
}
117+
"ipAddress": "0.0.0.0",
118+
},
116119
],
117120
"paid": 1,
118121
"daysLeft": 364,
119122
"sitePanelStatus": 1,
120-
"email": "em@em.com"
123+
"email": "em@em.com",
121124
}
122125
]
123126
}
@@ -130,6 +133,8 @@ def json(self):
130133

131134
mocker.patch("requests.get").return_value = StubResponse()
132135
client = mocker.patch("paradox.lib.stun.StunClient")
133-
client.return_value.receive_response.return_value = [{"attr_body": "abcdef", "name": "BEER"}]
136+
client.return_value.receive_response.return_value = [
137+
{"attr_body": "abcdef", "name": "BEER"}
138+
]
134139
await session.connect()
135-
return json_data
140+
return json_data

0 commit comments

Comments
 (0)