Skip to content

Commit

Permalink
Fix sort bug (#10)
Browse files Browse the repository at this point in the history
* sort error
  • Loading branch information
Kilo59 authored Jun 10, 2022
1 parent e1a1e08 commit 8b4b44b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion csv2http/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""_version"""
__version__ = "0.0.2a"
__version__ = "0.0.2a1"
6 changes: 5 additions & 1 deletion csv2http/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def summarize_responses(responses: list[Response]) -> str:
[getattr(r, "status_code", r.__class__.__name__) for r in responses]
)
# TODO: maybe don't bother sorting this
sorted_dict = dict(sorted(counter.items(), key=lambda item: item[0]))
sorted_dict = dict(
sorted(
counter.items(), key=lambda item: item[0] if isinstance(item[0], int) else 0
)
)
return f"status codes - {sorted_dict}"


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "csv2http"
version = "0.0.2a"
version = "0.0.2a1"
description = "Make http requests based on a CSV input file"
authors = ["Gabriel Gore <[email protected]>"]
license = "MIT License"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_csv2http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "0.0.2a"
assert __version__ == "0.0.2a1"
27 changes: 27 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import httpx
import pytest
from respx import MockResponse

from csv2http import utils


@pytest.mark.parametrize(
"responses",
[
[
MockResponse(200),
MockResponse(201),
httpx.ConnectTimeout("Ooops"),
MockResponse(201),
httpx.ConnectError("Oh no"),
]
],
)
def test_summarize_responses(responses):
summary = utils.summarize_responses(responses)
print(summary)
assert summary


if __name__ == "__main__":
pytest.main(["-vv"])

0 comments on commit 8b4b44b

Please sign in to comment.