Skip to content

Commit

Permalink
MNT: Add new linters for checking print statement and pytest style. T…
Browse files Browse the repository at this point in the history
…hen, fix the raised issues. [skip ci]
  • Loading branch information
Taher Chegini committed Oct 7, 2023
1 parent c3d50da commit 67d3961
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@pytest.fixture(autouse=True)
def add_standard_imports(doctest_namespace):
def _add_standard_imports(doctest_namespace):
"""Add async_retriever namespace for doctest."""
import async_retriever as ar

Expand Down
6 changes: 4 additions & 2 deletions tests/test_async_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_disable_cache():
payload = {"params": {"x": -101, "y": 38, "units": "Meters"}}
resp = ar.retrieve([url], "json", [payload], disable=True)
elev = float(resp[0]["value"])
assert abs(elev - 880.418) < SMALL and not asyncio.run(check_url(url, params=payload["params"]))
assert abs(elev - 880.418) < SMALL
assert not asyncio.run(check_url(url, params=payload["params"]))


def test_delete_url():
Expand All @@ -32,7 +33,8 @@ def test_delete_url():
resp = ar.retrieve([url], "json", [payload])
elev = float(resp[0]["value"])
ar.delete_url_cache(url, params=payload["params"])
assert abs(elev - 761.684) < SMALL and not asyncio.run(check_url(url, params=payload["params"]))
assert abs(elev - 761.684) < SMALL
assert not asyncio.run(check_url(url, params=payload["params"]))


def test_binary():
Expand Down
11 changes: 6 additions & 5 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from async_retriever import InputTypeError, InputValueError, ServiceError


@pytest.fixture
@pytest.fixture()
def url_kwds():
stations = ["01646500", "08072300", "11073495"]
url = "https://waterservices.usgs.gov/nwis/site"
Expand Down Expand Up @@ -91,14 +91,15 @@ def test_service_error():


def test_wrong_path_type():
urls = ["https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_CSV-1.csv"]
with pytest.raises(InputTypeError) as ex:
url = "https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_CSV-1.csv"
_ = ar.stream_write([url], "temp")
_ = ar.stream_write(urls, "temp")
assert "list of paths" in str(ex.value)


def test_wrong_path_number():
urls = ["https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_CSV-1.csv"]
file_paths = ["temp"] * 2
with pytest.raises(InputTypeError) as ex:
url = "https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_CSV-1.csv"
_ = ar.stream_write([url], ["temp"] * 2)
_ = ar.stream_write(urls, file_paths)
assert "same size" in str(ex.value)

0 comments on commit 67d3961

Please sign in to comment.