Skip to content

Commit

Permalink
adds new coloumn new_deaths and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nf1s committed May 30, 2021
1 parent a1e9419 commit b5f9faa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
10 changes: 5 additions & 5 deletions covid/worldometers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
""" Covid coronavirus statistics based on John Hopkins University statistics
"""
from pydantic import BaseModel, Field
from decimal import Decimal

from pydantic import BaseModel, Field

class CovidModel(BaseModel):
"""Dataclass acts as a Model for Covid data

"""
class CovidModel(BaseModel):
"""Dataclass acts as a Model for Covid data"""

country: str = Field(..., alias="Country,Other")
confirmed: int = Field(0, alias="TotalCases")
new_cases: int = Field(0, alias="NewCases")
deaths: int = Field(0, alias="TotalDeaths")
new_deaths: int = Field(0, alias="NewDeaths")
recovered: int = Field(0, alias="TotalRecovered")
active: int = Field(0, alias="ActiveCases")
critical: int = Field(0, alias="Serious,Critical")
Expand All @@ -27,4 +27,4 @@ class CovidModel(BaseModel):
total_deaths_per_million: Decimal = Field(
Decimal(0), alias="Deaths/1M pop"
)
population: Decimal = Field(Decimal(0), alias = "Population")
population: Decimal = Field(Decimal(0), alias="Population")
35 changes: 19 additions & 16 deletions tests/test_worldometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
""" tests module
"""
import pytest

from covid import Covid

covid = Covid("worldometers")
Expand All @@ -18,6 +19,7 @@ def test_all_data():
assert "deaths" in element
assert "recovered" in element
assert "new_cases" in element
assert "new_deaths" in element
assert "critical" in element
assert "new_deaths" in element
assert "total_tests" in element
Expand All @@ -28,22 +30,23 @@ def test_all_data():


def test_get_by_country_name():
data = covid.get_status_by_country_name("sweden")
assert type(data) is dict
assert "country" in data
assert "confirmed" in data
assert "active" in data
assert "deaths" in data
assert "recovered" in data
assert "new_cases" in data
assert "critical" in data
assert "new_deaths" in data
assert "total_tests" in data
assert "total_tests_per_million" in data
assert "total_cases_per_million" in data
assert "total_deaths_per_million" in data
assert "population" in data
assert data["country"] == "Sweden"
element = covid.get_status_by_country_name("sweden")
assert type(element) is dict
assert "country" in element
assert "confirmed" in element
assert "active" in element
assert "deaths" in element
assert "recovered" in element
assert "new_cases" in element
assert "new_deaths" in element
assert "critical" in element
assert "new_deaths" in element
assert "total_tests" in element
assert "total_tests_per_million" in element
assert "total_cases_per_million" in element
assert "total_deaths_per_million" in element
assert "population" in element
assert element["country"] == "Sweden"


def test_get_by_country_invalid_name():
Expand Down

0 comments on commit b5f9faa

Please sign in to comment.