Add dataframe column assertion
This commit is contained in:
parent
6849078d88
commit
a20dab0053
|
@ -1,5 +1,7 @@
|
|||
from json import dump
|
||||
|
||||
from requests import get
|
||||
|
||||
from constants import FILES, URL
|
||||
|
||||
|
||||
|
@ -22,6 +24,7 @@ def save_json(data, dataset):
|
|||
def request_dataset(dataset):
|
||||
"""
|
||||
Fetches the requested dataset from opendata's API
|
||||
Raises an exception if there's an HTTP error
|
||||
"""
|
||||
url = format_url(dataset)
|
||||
response = get(url)
|
|
@ -1,6 +1,8 @@
|
|||
from json import load
|
||||
from pandas import json_normalize, DataFrame
|
||||
from constants import FILES, COLUMNS
|
||||
|
||||
from pandas import DataFrame, json_normalize
|
||||
|
||||
from constants import COLUMNS, FILES
|
||||
|
||||
|
||||
def open_json(dataset) -> dict:
|
||||
|
|
|
@ -4,7 +4,6 @@ DATASETS = [
|
|||
"deconfinement-parking-relais-doublement-des-places",
|
||||
]
|
||||
URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1"
|
||||
TEST_URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset=deconfinement-pistes-cyclables-temporaires&rows=-1"
|
||||
FILES = {
|
||||
"deconfinement-pistes-cyclables-temporaires": "data/cycling-paths.json",
|
||||
"deconfinement-parking-relais-doublement-des-places": "data/relay-parking.json",
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from constants import FILES, DATASETS, URL
|
||||
from app.preprocessing import create_dataframe
|
||||
from app.request_datasets import request_dataset
|
||||
from os import remove
|
||||
|
||||
from pandas import DataFrame
|
||||
from requests import get
|
||||
from os import remove
|
||||
|
||||
from app.preprocessing import create_dataframe
|
||||
from app.data_request import request_dataset
|
||||
from constants import COLUMNS, DATASETS, FILES, URL
|
||||
|
||||
|
||||
def test_dataset_request():
|
||||
|
@ -24,3 +26,4 @@ def test_dataframe_creation():
|
|||
df = create_dataframe(dataset)
|
||||
remove(FILES[dataset])
|
||||
assert isinstance(df, DataFrame)
|
||||
assert all(df.columns == COLUMNS[dataset])
|
||||
|
|
Loading…
Reference in New Issue