From 67968a8ad34afb9260861c8259b6e1412f402aa6 Mon Sep 17 00:00:00 2001 From: coolneng Date: Wed, 27 May 2020 20:45:21 +0200 Subject: [PATCH] Add dataframe creation test --- app/constants.py | 6 +++--- app/preprocessing.py | 4 ++-- app/request_datasets.py | 2 +- tests/__init__.py | 0 tests/preprocessing_test.py | 9 +++++++++ 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/preprocessing_test.py diff --git a/app/constants.py b/app/constants.py index 01cf231..6d3324e 100644 --- a/app/constants.py +++ b/app/constants.py @@ -10,7 +10,7 @@ filenames = { "deconfinement-parking-relais-doublement-des-places": "relay-parking", } files = { - "cycling-paths": "../data/cycling-paths.json", - "relay-parking": "../data/relay-parking.json", - "home-delivery": "../data/home-delivery.json", + "cycling-paths": "data/cycling-paths.json", + "relay-parking": "data/relay-parking.json", + "home-delivery": "data/home-delivery.json", } diff --git a/app/preprocessing.py b/app/preprocessing.py index 8f2ac3a..49bb7da 100644 --- a/app/preprocessing.py +++ b/app/preprocessing.py @@ -1,6 +1,6 @@ from json import load -from pandas import read_json, json_normalize, DataFrame -from constants import files +from pandas import json_normalize, DataFrame +from app.constants import files def open_json(dataset): diff --git a/app/request_datasets.py b/app/request_datasets.py index 927cdab..0445acc 100644 --- a/app/request_datasets.py +++ b/app/request_datasets.py @@ -6,7 +6,7 @@ from json import dump, dumps def save_json(data, filename): - data_dir = "../data/" + data_dir = "data/" with open(data_dir + filename + ".json", "w") as f: dump(data, f, ensure_ascii=False) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/preprocessing_test.py b/tests/preprocessing_test.py new file mode 100644 index 0000000..b032f5b --- /dev/null +++ b/tests/preprocessing_test.py @@ -0,0 +1,9 @@ +from app.constants import files +from app.preprocessing import create_dataframe +from pandas import DataFrame + + +def test_dataframe_creation(): + for file in files.keys(): + df = create_dataframe(file) + assert isinstance(df, DataFrame)