Skip to content

Commit 8b4b44b

Browse files
authored
Fix sort bug (#10)
* sort error
1 parent e1a1e08 commit 8b4b44b

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

csv2http/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""_version"""
2-
__version__ = "0.0.2a"
2+
__version__ = "0.0.2a1"

csv2http/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ def summarize_responses(responses: list[Response]) -> str:
5656
[getattr(r, "status_code", r.__class__.__name__) for r in responses]
5757
)
5858
# TODO: maybe don't bother sorting this
59-
sorted_dict = dict(sorted(counter.items(), key=lambda item: item[0]))
59+
sorted_dict = dict(
60+
sorted(
61+
counter.items(), key=lambda item: item[0] if isinstance(item[0], int) else 0
62+
)
63+
)
6064
return f"status codes - {sorted_dict}"
6165

6266

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "csv2http"
7-
version = "0.0.2a"
7+
version = "0.0.2a1"
88
description = "Make http requests based on a CSV input file"
99
authors = ["Gabriel Gore <[email protected]>"]
1010
license = "MIT License"

tests/test_csv2http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def test_version():
5-
assert __version__ == "0.0.2a"
5+
assert __version__ == "0.0.2a1"

tests/test_utils.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import httpx
2+
import pytest
3+
from respx import MockResponse
4+
5+
from csv2http import utils
6+
7+
8+
@pytest.mark.parametrize(
9+
"responses",
10+
[
11+
[
12+
MockResponse(200),
13+
MockResponse(201),
14+
httpx.ConnectTimeout("Ooops"),
15+
MockResponse(201),
16+
httpx.ConnectError("Oh no"),
17+
]
18+
],
19+
)
20+
def test_summarize_responses(responses):
21+
summary = utils.summarize_responses(responses)
22+
print(summary)
23+
assert summary
24+
25+
26+
if __name__ == "__main__":
27+
pytest.main(["-vv"])

0 commit comments

Comments
 (0)