Skip to content

Commit

Permalink
🤖 black and isort files
Browse files Browse the repository at this point in the history
  • Loading branch information
codedawi committed May 20, 2020
1 parent 9d89eb3 commit 6a0bea5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
3 changes: 1 addition & 2 deletions app/utils/populations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import json
import logging

import requests

import app.io
import requests

LOGGER = logging.getLogger(__name__)
GEONAMES_URL = "http://api.geonames.org/countryInfoJSON"
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import os

import pytest
from async_asgi_testclient import TestClient as AsyncTestClient
from fastapi.testclient import TestClient

from app.main import APP
from app.utils import httputils
from async_asgi_testclient import TestClient as AsyncTestClient
from fastapi.testclient import TestClient

try:
from unittest.mock import AsyncMock
Expand Down
21 changes: 18 additions & 3 deletions tests/test_jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,24 @@ async def test_get_locations(mock_client_session):
@pytest.mark.parametrize(
"key, locations, index, expected",
[
(("Thailand", "TH"), [{"country": "Thailand", "province": "TH", "history": {"test": "yes"}}], 0, {"test": "yes"}), # Success
(("Deutschland", "DE"), [{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}], 1, {}), # IndexError
(("US", "NJ"), [{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}], 0, {}), # Invaid Key Merge
(
("Thailand", "TH"),
[{"country": "Thailand", "province": "TH", "history": {"test": "yes"}}],
0,
{"test": "yes"},
), # Success
(
("Deutschland", "DE"),
[{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}],
1,
{},
), # IndexError
(
("US", "NJ"),
[{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}],
0,
{},
), # Invaid Key Merge
],
)
def test_parse_history(key, locations, index, expected):
Expand Down
7 changes: 5 additions & 2 deletions tests/test_location_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from app.services.location import LocationService


class GoodLocationService(LocationService):
"""Valid LocationService Class."""

async def get_all(self):
"""
Gets and returns all of the locations.
Expand All @@ -16,8 +18,10 @@ async def get(self, id): # pylint: disable=redefined-builtin,invalid-name
"""
return id


class BadLocationService(LocationService):
"""Invalid LocationService Class."""

pass


Expand All @@ -32,5 +36,4 @@ async def test_location_service_invalid():
"""Test for location service interface valid class."""
good_loc_service = GoodLocationService()
assert [1] == await good_loc_service.get_all()
assert 1 == await good_loc_service.get(1)

assert 1 == await good_loc_service.get(1)
4 changes: 2 additions & 2 deletions tests/test_populations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""tests.test_populations.py"""
import pytest
import requests.exceptions
import responses

import app.io
import app.utils.populations
import requests.exceptions
import responses

NOT_FOUND_HTML = """<!DOCTYPE html>
<html lang="en">
Expand Down
4 changes: 2 additions & 2 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from unittest import mock

import pytest
from async_asgi_testclient import TestClient

from app.main import APP
from async_asgi_testclient import TestClient

from .conftest import mocked_strptime_isoformat
from .test_jhu import DATETIME_STRING
Expand Down Expand Up @@ -181,4 +181,4 @@ async def test_latest(async_api_client, query_params, mock_client_session):

assert response.status_code == 200
assert response_json["latest"]["confirmed"]
assert response_json["latest"]["deaths"]
assert response_json["latest"]["deaths"]

0 comments on commit 6a0bea5

Please sign in to comment.