Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yozik04 committed Sep 17, 2024
1 parent f1ba7f7 commit 5df1caa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
5 changes: 4 additions & 1 deletion tests/connection/ip/test_bare_connection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from unittest.mock import AsyncMock

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

create_connection_mock = AsyncMock(return_value=(None, protocol))
mocker.patch.object(connection.loop, "create_connection", create_connection_mock)
mocker.patch.object(
asyncio.get_event_loop(), "create_connection", create_connection_mock
)

assert connection.connected is False

Expand Down
5 changes: 4 additions & 1 deletion tests/connection/ip/test_local_ip_connection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from unittest.mock import AsyncMock

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

create_connection_mock = AsyncMock(return_value=(None, protocol))
mocker.patch.object(connection.loop, "create_connection", create_connection_mock)
mocker.patch.object(
asyncio.get_event_loop(), "create_connection", create_connection_mock
)
connect_command_execute = mocker.patch.object(
IPModuleConnectCommand, "execute", AsyncMock()
)
Expand Down
23 changes: 14 additions & 9 deletions tests/connection/ip/test_stun_ip_connection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from unittest.mock import AsyncMock

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

create_connection_mock = AsyncMock(return_value=(None, protocol))
mocker.patch.object(connection.loop, "create_connection", create_connection_mock)
mocker.patch.object(
asyncio.get_event_loop(), "create_connection", create_connection_mock
)
connect_command_execute = mocker.patch.object(
IPModuleConnectCommand, "execute", AsyncMock()
)
Expand Down Expand Up @@ -74,7 +77,7 @@ async def assert_session_connect(mocker, session):
"serial": "bf4c1fe4",
"type": "HD77",
"port": 54321,
"panelSerial": "0584b067"
"panelSerial": "0584b067",
},
{
"lastUpdate": "2021-05-07T15:41:19Z",
Expand All @@ -85,7 +88,7 @@ async def assert_session_connect(mocker, session):
"serial": "465e81a0",
"type": "HD88",
"port": 12345,
"panelSerial": "0584b067"
"panelSerial": "0584b067",
},
{
"lastUpdate": "2021-05-07T15:41:19Z",
Expand All @@ -98,7 +101,7 @@ async def assert_session_connect(mocker, session):
"panelSerial": "a72ed4bf",
"xoraddr": "9a640069cda9b317",
"API": None,
"ipAddress": "0.0.0.0"
"ipAddress": "0.0.0.0",
},
{
"lastUpdate": "2021-05-07T15:41:19Z",
Expand All @@ -111,13 +114,13 @@ async def assert_session_connect(mocker, session):
"panelSerial": "0584b067",
"xoraddr": "c351472f48a5e1ba",
"API": None,
"ipAddress": "0.0.0.0"
}
"ipAddress": "0.0.0.0",
},
],
"paid": 1,
"daysLeft": 364,
"sitePanelStatus": 1,
"email": "em@em.com"
"email": "em@em.com",
}
]
}
Expand All @@ -130,6 +133,8 @@ def json(self):

mocker.patch("requests.get").return_value = StubResponse()
client = mocker.patch("paradox.lib.stun.StunClient")
client.return_value.receive_response.return_value = [{"attr_body": "abcdef", "name": "BEER"}]
client.return_value.receive_response.return_value = [
{"attr_body": "abcdef", "name": "BEER"}
]
await session.connect()
return json_data
return json_data

0 comments on commit 5df1caa

Please sign in to comment.