Skip to content

Commit 9c83f42

Browse files
author
Tom Softreck
committed
update
1 parent 175d55e commit 9c83f42

File tree

2 files changed

+77
-35
lines changed

2 files changed

+77
-35
lines changed

pyproject.toml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,49 @@ numpy = ">=1.21.0,<2.0.0"
4444
python-nmap = ">=0.7.1,<1.0.0"
4545

4646
[tool.poetry.group.dev.dependencies]
47+
# Code formatting
4748
black = "^23.0.0"
49+
isort = "^5.12.0"
50+
51+
# Linting
4852
flake8 = "^6.0.0"
4953
flake8-bugbear = "^23.7.0"
50-
isort = "^5.12.0"
51-
mypy = "^1.0.0"
52-
pre-commit = "^3.0.0"
53-
54-
[tool.poetry.group.test.dependencies]
55-
pytest = "^7.0.0"
56-
pytest-asyncio = "^0.21.0"
57-
pytest-cov = "^4.0.0"
58-
pytest-mock = "^3.10.0"
59-
pytest-aiohttp = "^1.0.0"
60-
coverage = {extras = ["toml"], version = "^7.0.0"}
54+
flake8-annotations = "^3.0.1"
55+
flake8-bandit = "^4.1.1"
56+
flake8-docstrings = "^1.7.0"
57+
flake8-import-order = "^0.18.2"
58+
pep8-naming = "^0.13.3"
59+
60+
# Type checking
61+
mypy = "^1.5.0"
62+
types-PyYAML = "^6.0.12"
63+
types-requests = "^2.31.0"
64+
types-python-dateutil = "^2.8.19"
65+
66+
# Testing
67+
pytest = "^7.4.0"
68+
pytest-asyncio = "^0.21.1"
69+
pytest-cov = "^4.1.0"
70+
pytest-mock = "^3.11.1"
71+
pytest-aiohttp = "^1.0.5"
72+
pytest-xdist = "^3.3.1"
73+
coverage = {extras = ["toml"], version = "^7.3.0"}
74+
75+
# Documentation
76+
sphinx = "^7.0.1"
77+
sphinx-rtd-theme = "^1.2.2"
78+
sphinx-autodoc-typehints = "^1.23.0"
79+
sphinx-copybutton = "^0.5.2"
80+
81+
# Development tools
82+
pre-commit = "^3.3.3"
83+
invoke = "^2.1.2"
84+
bandit = "^1.7.5"
85+
safety = "^2.3.5"
86+
vulture = "^2.7"
87+
88+
# Type stubs
89+
typing-extensions = "^4.6.3"
6190

6291
[tool.poetry.scripts]
6392
dialogchain = "dialogchain.cli:main"

tests/integration/test_http_connector.py

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,61 +34,74 @@ async def handle_echo(request: web.Request) -> web.Response:
3434
return runner, f"http://localhost:{unused_tcp_port}"
3535

3636
@pytest.mark.asyncio
37-
async def test_http_connector_with_mock_server(self, mock_http_server: tuple[web.AppRunner, str]) -> None:
38-
"""Test HTTP connector with a mock HTTP server"""
37+
async def test_http_connector_with_mock_server(
38+
self, mock_http_server: tuple[web.AppRunner, str]
39+
) -> None:
40+
"""Test HTTP connector with a mock HTTP server.
41+
42+
Args:
43+
mock_http_server: Fixture that provides a mock HTTP server.
44+
"""
3945
runner, server_url = mock_http_server
40-
46+
4147
# Start the mock server
4248
await runner.setup()
43-
site = web.TCPSite(runner, "localhost", int(server_url.split(":")[-1]))
49+
site = web.TCPSite(runner, 'localhost', int(server_url.split(':')[-1]))
4450
await site.start()
45-
51+
4652
try:
4753
# Test the HTTP connector
4854
connector = HTTPDestination(f"{server_url}/echo")
4955
test_data = {"test": "data"}
50-
56+
5157
# Mock the session to capture the request
52-
with patch("aiohttp.ClientSession.post") as mock_post:
58+
with patch('aiohttp.ClientSession.post') as mock_post:
5359
mock_response = MagicMock()
5460
mock_response.__aenter__.return_value.status = 200
55-
mock_response.__aenter__.return_value.json.return_value = {
56-
"echo": test_data
57-
}
61+
mock_response.__aenter__.return_value.json.return_value = {"echo": test_data}
5862
mock_post.return_value = mock_response
59-
63+
6064
await connector.send(test_data)
61-
65+
6266
# Verify the request was made correctly
63-
mock_post.assert_called_once_with(f"{server_url}/echo", json=test_data)
64-
67+
mock_post.assert_called_once_with(
68+
f"{server_url}/echo",
69+
json=test_data
70+
)
71+
6572
finally:
6673
# Clean up the server
6774
await runner.cleanup()
68-
75+
6976
@pytest.mark.asyncio
70-
async def test_http_connector_with_real_request(self, mock_http_server):
71-
"""Test HTTP connector with a real request to mock server"""
77+
async def test_http_connector_with_real_request(
78+
self, mock_http_server: tuple[web.AppRunner, str]
79+
) -> None:
80+
"""Test HTTP connector with a real request to mock server.
81+
82+
Args:
83+
mock_http_server: Fixture that provides a mock HTTP server.
84+
"""
7285
runner, server_url = mock_http_server
73-
86+
7487
# Start the mock server
7588
await runner.setup()
76-
site = web.TCPSite(runner, "localhost", int(server_url.split(":")[-1]))
89+
site = web.TCPSite(runner, 'localhost', int(server_url.split(':')[-1]))
7790
await site.start()
78-
91+
7992
try:
8093
# Test the HTTP connector with a real request
8194
connector = HTTPDestination(f"{server_url}/echo")
8295
test_data = {"message": "Hello, World!"}
83-
96+
8497
# This will make a real HTTP request to our mock server
8598
async with aiohttp.ClientSession() as session:
86-
with patch("aiohttp.ClientSession", return_value=session):
99+
with patch('aiohttp.ClientSession', return_value=session):
87100
await connector.send(test_data)
88-
101+
89102
# Verify the request was made by checking the server logs
90103
# or other side effects if needed
91-
104+
92105
finally:
93106
# Clean up the server
94107
await runner.cleanup()

0 commit comments

Comments
 (0)