first commit
This commit is contained in:
31
tests/test_data_fetcher.py
Normal file
31
tests/test_data_fetcher.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Přidání adresáře src do sys.path, aby bylo možné importovat moduly
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
import data_fetcher
|
||||
|
||||
def test_download_yearly_data():
|
||||
"""Test stahování ročních dat pro rok 2020."""
|
||||
print("Spouštím test stahování ročních dat pro rok 2020...")
|
||||
# Ujistěme se, že adresář data existuje
|
||||
os.makedirs("data", exist_ok=True)
|
||||
|
||||
# Volání funkce pro stažení dat
|
||||
file_path = data_fetcher.download_yearly_data(2020, output_dir="data")
|
||||
|
||||
# Ověření výsledku
|
||||
if file_path and os.path.exists(file_path):
|
||||
print(f"Test úspěšný: Data byla stažena a uložena do {file_path}")
|
||||
|
||||
# Zkontrolujme, zda soubor není prázdný
|
||||
if os.path.getsize(file_path) > 0:
|
||||
print("Test úspěšný: Soubor není prázdný.")
|
||||
else:
|
||||
print("Test selhal: Soubor je prázdný.")
|
||||
else:
|
||||
print("Test selhal: Nepodařilo se stáhnout data.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_download_yearly_data()
|
||||
Reference in New Issue
Block a user