meteocatpy 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +33 -33
- package/.gitlab-ci.yml +46 -46
- package/.pre-commit-config.yaml +37 -37
- package/.releaserc +23 -23
- package/.releaserc.toml +14 -14
- package/AUTHORS.md +12 -12
- package/CHANGELOG.md +187 -171
- package/README.md +61 -61
- package/filetree.py +48 -48
- package/filetree.txt +48 -48
- package/meteocatpy/README.md +61 -61
- package/meteocatpy/__init__.py +27 -27
- package/meteocatpy/const.py +10 -10
- package/meteocatpy/data.py +93 -93
- package/meteocatpy/exceptions.py +35 -35
- package/meteocatpy/forecast.py +137 -137
- package/meteocatpy/helpers.py +46 -46
- package/meteocatpy/stations.py +71 -71
- package/meteocatpy/symbols.py +89 -89
- package/meteocatpy/town.py +61 -61
- package/meteocatpy/townstations.py +99 -99
- package/meteocatpy/variables.py +77 -77
- package/meteocatpy/version.py +2 -2
- package/package.json +23 -23
- package/poetry.lock +3313 -3313
- package/pyproject.toml +72 -72
- package/releaserc.json +17 -17
- package/requirements.test.txt +3 -3
- package/setup.cfg +64 -64
- package/setup.py +10 -10
- package/tests/data_test.py +122 -122
- package/tests/import_test.py +18 -18
- package/tests/integration_test_complete.py +76 -76
- package/tests/integration_test_forecast.py +54 -54
- package/tests/integration_test_station_data.py +33 -33
- package/tests/integration_test_stations.py +31 -31
- package/tests/integration_test_symbols.py +68 -68
- package/tests/integration_test_town.py +32 -32
- package/tests/integration_test_town_stations.py +36 -36
- package/tests/integration_test_variables.py +32 -32
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
import json
|
|
4
|
-
from dotenv import load_dotenv
|
|
5
|
-
from meteocatpy.town import MeteocatTown
|
|
6
|
-
from meteocatpy.forecast import MeteocatForecast
|
|
7
|
-
|
|
8
|
-
# Cargar variables desde el archivo .env
|
|
9
|
-
load_dotenv()
|
|
10
|
-
|
|
11
|
-
# Obtener los valores del archivo .env
|
|
12
|
-
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
13
|
-
MUNICIPI_TEST = os.getenv("MUNICIPI_TEST")
|
|
14
|
-
MUNICIPI_CODI_TEST = os.getenv("MUNICIPI_CODI_TEST")
|
|
15
|
-
|
|
16
|
-
# Asegúrate de que las variables estén definidas
|
|
17
|
-
assert API_KEY, "API Key is required"
|
|
18
|
-
assert MUNICIPI_TEST, "Municipi test is required"
|
|
19
|
-
assert MUNICIPI_CODI_TEST, "Municipi codi test is required"
|
|
20
|
-
|
|
21
|
-
@pytest.mark.asyncio
|
|
22
|
-
async def test_municipis():
|
|
23
|
-
# Crear una instancia de MeteocatTown con la API Key
|
|
24
|
-
town_client = MeteocatTown(API_KEY)
|
|
25
|
-
|
|
26
|
-
# Obtener los municipios
|
|
27
|
-
municipios_data = await town_client.get_municipis()
|
|
28
|
-
|
|
29
|
-
# Crear la carpeta si no existe
|
|
30
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
31
|
-
|
|
32
|
-
# Guardar los datos de los municipios en un archivo JSON
|
|
33
|
-
with open('tests/files/municipis.json', 'w', encoding='utf-8') as f:
|
|
34
|
-
json.dump(municipios_data, f, ensure_ascii=False, indent=4)
|
|
35
|
-
|
|
36
|
-
# Verificar que los municipios no estén vacíos
|
|
37
|
-
assert municipios_data, "Municipis data is empty"
|
|
38
|
-
|
|
39
|
-
# Verificar que el municipio de prueba esté en la lista
|
|
40
|
-
municipi_names = [m['nom'] for m in municipios_data]
|
|
41
|
-
assert MUNICIPI_TEST in municipi_names, f"{MUNICIPI_TEST} not found in municipis list"
|
|
42
|
-
|
|
43
|
-
@pytest.mark.asyncio
|
|
44
|
-
async def test_predict_horaria():
|
|
45
|
-
# Crear una instancia de MeteocatForecast con la API Key
|
|
46
|
-
forecast_client = MeteocatForecast(API_KEY)
|
|
47
|
-
|
|
48
|
-
# Obtener la predicción horaria para el municipio de prueba
|
|
49
|
-
prediccion_hora = await forecast_client.get_prediccion_horaria(MUNICIPI_CODI_TEST)
|
|
50
|
-
|
|
51
|
-
# Crear la carpeta si no existe
|
|
52
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
53
|
-
|
|
54
|
-
# Guardar la predicción horaria en un archivo JSON
|
|
55
|
-
with open('tests/files/predict_hora.json', 'w', encoding='utf-8') as f:
|
|
56
|
-
json.dump(prediccion_hora, f, ensure_ascii=False, indent=4)
|
|
57
|
-
|
|
58
|
-
# Verificar que la predicción horaria no esté vacía
|
|
59
|
-
assert prediccion_hora, "Prediccion horaria is empty"
|
|
60
|
-
|
|
61
|
-
@pytest.mark.asyncio
|
|
62
|
-
async def test_predict_diaria():
|
|
63
|
-
# Crear una instancia de MeteocatForecast con la API Key
|
|
64
|
-
forecast_client = MeteocatForecast(API_KEY)
|
|
65
|
-
|
|
66
|
-
# Obtener la predicción diaria para el municipio de prueba
|
|
67
|
-
prediccion_dia = await forecast_client.get_prediccion_diaria(MUNICIPI_CODI_TEST)
|
|
68
|
-
|
|
69
|
-
# Crear la carpeta si no existe
|
|
70
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
71
|
-
|
|
72
|
-
# Guardar la predicción diaria en un archivo JSON
|
|
73
|
-
with open('tests/files/predict_dia.json', 'w', encoding='utf-8') as f:
|
|
74
|
-
json.dump(prediccion_dia, f, ensure_ascii=False, indent=4)
|
|
75
|
-
|
|
76
|
-
# Verificar que la predicción diaria no esté vacía
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
import json
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from meteocatpy.town import MeteocatTown
|
|
6
|
+
from meteocatpy.forecast import MeteocatForecast
|
|
7
|
+
|
|
8
|
+
# Cargar variables desde el archivo .env
|
|
9
|
+
load_dotenv()
|
|
10
|
+
|
|
11
|
+
# Obtener los valores del archivo .env
|
|
12
|
+
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
13
|
+
MUNICIPI_TEST = os.getenv("MUNICIPI_TEST")
|
|
14
|
+
MUNICIPI_CODI_TEST = os.getenv("MUNICIPI_CODI_TEST")
|
|
15
|
+
|
|
16
|
+
# Asegúrate de que las variables estén definidas
|
|
17
|
+
assert API_KEY, "API Key is required"
|
|
18
|
+
assert MUNICIPI_TEST, "Municipi test is required"
|
|
19
|
+
assert MUNICIPI_CODI_TEST, "Municipi codi test is required"
|
|
20
|
+
|
|
21
|
+
@pytest.mark.asyncio
|
|
22
|
+
async def test_municipis():
|
|
23
|
+
# Crear una instancia de MeteocatTown con la API Key
|
|
24
|
+
town_client = MeteocatTown(API_KEY)
|
|
25
|
+
|
|
26
|
+
# Obtener los municipios
|
|
27
|
+
municipios_data = await town_client.get_municipis()
|
|
28
|
+
|
|
29
|
+
# Crear la carpeta si no existe
|
|
30
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
31
|
+
|
|
32
|
+
# Guardar los datos de los municipios en un archivo JSON
|
|
33
|
+
with open('tests/files/municipis.json', 'w', encoding='utf-8') as f:
|
|
34
|
+
json.dump(municipios_data, f, ensure_ascii=False, indent=4)
|
|
35
|
+
|
|
36
|
+
# Verificar que los municipios no estén vacíos
|
|
37
|
+
assert municipios_data, "Municipis data is empty"
|
|
38
|
+
|
|
39
|
+
# Verificar que el municipio de prueba esté en la lista
|
|
40
|
+
municipi_names = [m['nom'] for m in municipios_data]
|
|
41
|
+
assert MUNICIPI_TEST in municipi_names, f"{MUNICIPI_TEST} not found in municipis list"
|
|
42
|
+
|
|
43
|
+
@pytest.mark.asyncio
|
|
44
|
+
async def test_predict_horaria():
|
|
45
|
+
# Crear una instancia de MeteocatForecast con la API Key
|
|
46
|
+
forecast_client = MeteocatForecast(API_KEY)
|
|
47
|
+
|
|
48
|
+
# Obtener la predicción horaria para el municipio de prueba
|
|
49
|
+
prediccion_hora = await forecast_client.get_prediccion_horaria(MUNICIPI_CODI_TEST)
|
|
50
|
+
|
|
51
|
+
# Crear la carpeta si no existe
|
|
52
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
53
|
+
|
|
54
|
+
# Guardar la predicción horaria en un archivo JSON
|
|
55
|
+
with open('tests/files/predict_hora.json', 'w', encoding='utf-8') as f:
|
|
56
|
+
json.dump(prediccion_hora, f, ensure_ascii=False, indent=4)
|
|
57
|
+
|
|
58
|
+
# Verificar que la predicción horaria no esté vacía
|
|
59
|
+
assert prediccion_hora, "Prediccion horaria is empty"
|
|
60
|
+
|
|
61
|
+
@pytest.mark.asyncio
|
|
62
|
+
async def test_predict_diaria():
|
|
63
|
+
# Crear una instancia de MeteocatForecast con la API Key
|
|
64
|
+
forecast_client = MeteocatForecast(API_KEY)
|
|
65
|
+
|
|
66
|
+
# Obtener la predicción diaria para el municipio de prueba
|
|
67
|
+
prediccion_dia = await forecast_client.get_prediccion_diaria(MUNICIPI_CODI_TEST)
|
|
68
|
+
|
|
69
|
+
# Crear la carpeta si no existe
|
|
70
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
71
|
+
|
|
72
|
+
# Guardar la predicción diaria en un archivo JSON
|
|
73
|
+
with open('tests/files/predict_dia.json', 'w', encoding='utf-8') as f:
|
|
74
|
+
json.dump(prediccion_dia, f, ensure_ascii=False, indent=4)
|
|
75
|
+
|
|
76
|
+
# Verificar que la predicción diaria no esté vacía
|
|
77
77
|
assert prediccion_dia, "Prediccion diaria is empty"
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
import json
|
|
4
|
-
from dotenv import load_dotenv
|
|
5
|
-
from meteocatpy.forecast import MeteocatForecast
|
|
6
|
-
|
|
7
|
-
# Cargar variables desde el archivo .env
|
|
8
|
-
load_dotenv()
|
|
9
|
-
|
|
10
|
-
# Obtener los valores del archivo .env
|
|
11
|
-
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
-
MUNICIPI_TEST = os.getenv("MUNICIPI_TEST")
|
|
13
|
-
MUNICIPI_CODI_TEST = os.getenv("MUNICIPI_CODI_TEST")
|
|
14
|
-
|
|
15
|
-
# Asegúrate de que las variables estén definidas
|
|
16
|
-
assert API_KEY, "API Key is required"
|
|
17
|
-
assert MUNICIPI_TEST, "Municipi test is required"
|
|
18
|
-
assert MUNICIPI_CODI_TEST, "Municipi codi test is required"
|
|
19
|
-
|
|
20
|
-
@pytest.mark.asyncio
|
|
21
|
-
async def test_predict_horaria():
|
|
22
|
-
# Crear una instancia de MeteocatForecast con la API Key
|
|
23
|
-
forecast_client = MeteocatForecast(API_KEY)
|
|
24
|
-
|
|
25
|
-
# Obtener la predicción horaria para el municipio de prueba
|
|
26
|
-
prediccion_hora = await forecast_client.get_prediccion_horaria(MUNICIPI_CODI_TEST)
|
|
27
|
-
|
|
28
|
-
# Crear la carpeta si no existe
|
|
29
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
30
|
-
|
|
31
|
-
# Guardar la predicción horaria en un archivo JSON
|
|
32
|
-
with open('tests/files/predict_hora.json', 'w', encoding='utf-8') as f:
|
|
33
|
-
json.dump(prediccion_hora, f, ensure_ascii=False, indent=4)
|
|
34
|
-
|
|
35
|
-
# Verificar que la predicción horaria no esté vacía
|
|
36
|
-
assert prediccion_hora, "Prediccion horaria is empty"
|
|
37
|
-
|
|
38
|
-
@pytest.mark.asyncio
|
|
39
|
-
async def test_predict_diaria():
|
|
40
|
-
# Crear una instancia de MeteocatForecast con la API Key
|
|
41
|
-
forecast_client = MeteocatForecast(API_KEY)
|
|
42
|
-
|
|
43
|
-
# Obtener la predicción diaria para el municipio de prueba
|
|
44
|
-
prediccion_dia = await forecast_client.get_prediccion_diaria(MUNICIPI_CODI_TEST)
|
|
45
|
-
|
|
46
|
-
# Crear la carpeta si no existe
|
|
47
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
48
|
-
|
|
49
|
-
# Guardar la predicción diaria en un archivo JSON
|
|
50
|
-
with open('tests/files/predict_dia.json', 'w', encoding='utf-8') as f:
|
|
51
|
-
json.dump(prediccion_dia, f, ensure_ascii=False, indent=4)
|
|
52
|
-
|
|
53
|
-
# Verificar que la predicción diaria no esté vacía
|
|
54
|
-
assert prediccion_dia, "Prediccion diaria is empty"
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
import json
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from meteocatpy.forecast import MeteocatForecast
|
|
6
|
+
|
|
7
|
+
# Cargar variables desde el archivo .env
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
# Obtener los valores del archivo .env
|
|
11
|
+
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
+
MUNICIPI_TEST = os.getenv("MUNICIPI_TEST")
|
|
13
|
+
MUNICIPI_CODI_TEST = os.getenv("MUNICIPI_CODI_TEST")
|
|
14
|
+
|
|
15
|
+
# Asegúrate de que las variables estén definidas
|
|
16
|
+
assert API_KEY, "API Key is required"
|
|
17
|
+
assert MUNICIPI_TEST, "Municipi test is required"
|
|
18
|
+
assert MUNICIPI_CODI_TEST, "Municipi codi test is required"
|
|
19
|
+
|
|
20
|
+
@pytest.mark.asyncio
|
|
21
|
+
async def test_predict_horaria():
|
|
22
|
+
# Crear una instancia de MeteocatForecast con la API Key
|
|
23
|
+
forecast_client = MeteocatForecast(API_KEY)
|
|
24
|
+
|
|
25
|
+
# Obtener la predicción horaria para el municipio de prueba
|
|
26
|
+
prediccion_hora = await forecast_client.get_prediccion_horaria(MUNICIPI_CODI_TEST)
|
|
27
|
+
|
|
28
|
+
# Crear la carpeta si no existe
|
|
29
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
30
|
+
|
|
31
|
+
# Guardar la predicción horaria en un archivo JSON
|
|
32
|
+
with open('tests/files/predict_hora.json', 'w', encoding='utf-8') as f:
|
|
33
|
+
json.dump(prediccion_hora, f, ensure_ascii=False, indent=4)
|
|
34
|
+
|
|
35
|
+
# Verificar que la predicción horaria no esté vacía
|
|
36
|
+
assert prediccion_hora, "Prediccion horaria is empty"
|
|
37
|
+
|
|
38
|
+
@pytest.mark.asyncio
|
|
39
|
+
async def test_predict_diaria():
|
|
40
|
+
# Crear una instancia de MeteocatForecast con la API Key
|
|
41
|
+
forecast_client = MeteocatForecast(API_KEY)
|
|
42
|
+
|
|
43
|
+
# Obtener la predicción diaria para el municipio de prueba
|
|
44
|
+
prediccion_dia = await forecast_client.get_prediccion_diaria(MUNICIPI_CODI_TEST)
|
|
45
|
+
|
|
46
|
+
# Crear la carpeta si no existe
|
|
47
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
48
|
+
|
|
49
|
+
# Guardar la predicción diaria en un archivo JSON
|
|
50
|
+
with open('tests/files/predict_dia.json', 'w', encoding='utf-8') as f:
|
|
51
|
+
json.dump(prediccion_dia, f, ensure_ascii=False, indent=4)
|
|
52
|
+
|
|
53
|
+
# Verificar que la predicción diaria no esté vacía
|
|
54
|
+
assert prediccion_dia, "Prediccion diaria is empty"
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
import json
|
|
4
|
-
from dotenv import load_dotenv
|
|
5
|
-
from meteocatpy.data import MeteocatStationData
|
|
6
|
-
|
|
7
|
-
# Cargar variables desde el archivo .env
|
|
8
|
-
load_dotenv()
|
|
9
|
-
|
|
10
|
-
# Obtener los valores del archivo .env
|
|
11
|
-
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
-
STATION_CODI_TEST = os.getenv("STATION_CODI_TEST")
|
|
13
|
-
|
|
14
|
-
# Asegúrate de que las variables estén definidas
|
|
15
|
-
assert API_KEY, "API Key is required"
|
|
16
|
-
assert STATION_CODI_TEST, "Station codi test is required"
|
|
17
|
-
|
|
18
|
-
@pytest.mark.asyncio
|
|
19
|
-
async def test_stations_data():
|
|
20
|
-
# Crear una instancia de MeteocatStationData con la API Key
|
|
21
|
-
data_client = MeteocatStationData(API_KEY)
|
|
22
|
-
|
|
23
|
-
# Obtener los datos de la estación
|
|
24
|
-
station_data = await data_client.get_station_data(STATION_CODI_TEST)
|
|
25
|
-
|
|
26
|
-
# Crear la carpeta si no existe
|
|
27
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
28
|
-
|
|
29
|
-
# Guardar los datos de las estaciones en un archivo JSON
|
|
30
|
-
with open(f'tests/files/station_{STATION_CODI_TEST}_data.json', 'w', encoding='utf-8') as f:
|
|
31
|
-
json.dump(station_data, f, ensure_ascii=False, indent=4)
|
|
32
|
-
|
|
33
|
-
# Verificar que los datos no estén vacíos
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
import json
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from meteocatpy.data import MeteocatStationData
|
|
6
|
+
|
|
7
|
+
# Cargar variables desde el archivo .env
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
# Obtener los valores del archivo .env
|
|
11
|
+
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
+
STATION_CODI_TEST = os.getenv("STATION_CODI_TEST")
|
|
13
|
+
|
|
14
|
+
# Asegúrate de que las variables estén definidas
|
|
15
|
+
assert API_KEY, "API Key is required"
|
|
16
|
+
assert STATION_CODI_TEST, "Station codi test is required"
|
|
17
|
+
|
|
18
|
+
@pytest.mark.asyncio
|
|
19
|
+
async def test_stations_data():
|
|
20
|
+
# Crear una instancia de MeteocatStationData con la API Key
|
|
21
|
+
data_client = MeteocatStationData(API_KEY)
|
|
22
|
+
|
|
23
|
+
# Obtener los datos de la estación
|
|
24
|
+
station_data = await data_client.get_station_data(STATION_CODI_TEST)
|
|
25
|
+
|
|
26
|
+
# Crear la carpeta si no existe
|
|
27
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
28
|
+
|
|
29
|
+
# Guardar los datos de las estaciones en un archivo JSON
|
|
30
|
+
with open(f'tests/files/station_{STATION_CODI_TEST}_data.json', 'w', encoding='utf-8') as f:
|
|
31
|
+
json.dump(station_data, f, ensure_ascii=False, indent=4)
|
|
32
|
+
|
|
33
|
+
# Verificar que los datos no estén vacíos
|
|
34
34
|
assert station_data, "Estaciones data is empty"
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
import json
|
|
4
|
-
from dotenv import load_dotenv
|
|
5
|
-
from meteocatpy.stations import MeteocatStations
|
|
6
|
-
|
|
7
|
-
# Cargar variables desde el archivo .env
|
|
8
|
-
load_dotenv()
|
|
9
|
-
|
|
10
|
-
# Obtener los valores del archivo .env
|
|
11
|
-
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
-
|
|
13
|
-
# Asegúrate de que las variables estén definidas
|
|
14
|
-
assert API_KEY, "API Key is required"
|
|
15
|
-
|
|
16
|
-
@pytest.mark.asyncio
|
|
17
|
-
async def test_stations():
|
|
18
|
-
# Crear una instancia de MeteocatStations con la API Key
|
|
19
|
-
stations_client = MeteocatStations(API_KEY)
|
|
20
|
-
|
|
21
|
-
# Obtener las estaciones
|
|
22
|
-
stations_data = await stations_client.get_stations()
|
|
23
|
-
|
|
24
|
-
# Crear la carpeta si no existe
|
|
25
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
26
|
-
|
|
27
|
-
# Guardar los datos de las estaciones en un archivo JSON
|
|
28
|
-
with open('tests/files/stations.json', 'w', encoding='utf-8') as f:
|
|
29
|
-
json.dump(stations_data, f, ensure_ascii=False, indent=4)
|
|
30
|
-
|
|
31
|
-
# Verificar que los municipios no estén vacíos
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
import json
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from meteocatpy.stations import MeteocatStations
|
|
6
|
+
|
|
7
|
+
# Cargar variables desde el archivo .env
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
# Obtener los valores del archivo .env
|
|
11
|
+
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
+
|
|
13
|
+
# Asegúrate de que las variables estén definidas
|
|
14
|
+
assert API_KEY, "API Key is required"
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_stations():
|
|
18
|
+
# Crear una instancia de MeteocatStations con la API Key
|
|
19
|
+
stations_client = MeteocatStations(API_KEY)
|
|
20
|
+
|
|
21
|
+
# Obtener las estaciones
|
|
22
|
+
stations_data = await stations_client.get_stations()
|
|
23
|
+
|
|
24
|
+
# Crear la carpeta si no existe
|
|
25
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
26
|
+
|
|
27
|
+
# Guardar los datos de las estaciones en un archivo JSON
|
|
28
|
+
with open('tests/files/stations.json', 'w', encoding='utf-8') as f:
|
|
29
|
+
json.dump(stations_data, f, ensure_ascii=False, indent=4)
|
|
30
|
+
|
|
31
|
+
# Verificar que los municipios no estén vacíos
|
|
32
32
|
assert stations_data, "Estaciones data is empty"
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
import json
|
|
4
|
-
from dotenv import load_dotenv
|
|
5
|
-
from meteocatpy.symbols import MeteocatSymbols
|
|
6
|
-
|
|
7
|
-
# Cargar variables desde el archivo .env
|
|
8
|
-
load_dotenv()
|
|
9
|
-
|
|
10
|
-
# Obtener los valores del archivo .env
|
|
11
|
-
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
-
|
|
13
|
-
# Asegúrate de que las variables estén definidas
|
|
14
|
-
assert API_KEY, "API Key is required"
|
|
15
|
-
|
|
16
|
-
@pytest.mark.asyncio
|
|
17
|
-
async def test_simbols():
|
|
18
|
-
# Crear una instancia de MeteocatSymbols con la API Key
|
|
19
|
-
symbols_client = MeteocatSymbols(API_KEY)
|
|
20
|
-
|
|
21
|
-
# Obtener los símbolos
|
|
22
|
-
simbolos_data = await symbols_client.fetch_symbols()
|
|
23
|
-
|
|
24
|
-
# Verificar la estructura de los datos obtenidos
|
|
25
|
-
print("Estructura de los datos obtenidos:")
|
|
26
|
-
print(simbolos_data) # Esto te mostrará si realmente es una lista de categorías
|
|
27
|
-
|
|
28
|
-
# Crear la carpeta si no existe
|
|
29
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
30
|
-
|
|
31
|
-
# Guardar el JSON completo original
|
|
32
|
-
with open('tests/files/simbols.json', 'w', encoding='utf-8') as f:
|
|
33
|
-
json.dump(simbolos_data, f, ensure_ascii=False, indent=4)
|
|
34
|
-
|
|
35
|
-
# Verificar que los símbolos no estén vacíos
|
|
36
|
-
assert simbolos_data, "Simbols data is empty"
|
|
37
|
-
|
|
38
|
-
# Iterar sobre las categorías y guardar cada una en su propio archivo
|
|
39
|
-
for category in simbolos_data:
|
|
40
|
-
if "valors" in category: # Asegurarse de que tenga "valors"
|
|
41
|
-
category_name = category['nom'] # Nombre de la categoría (e.g., "cel", "mar", etc.)
|
|
42
|
-
|
|
43
|
-
# Reemplazar los espacios por guiones bajos en el nombre de la categoría
|
|
44
|
-
category_name_safe = category_name.replace(' ', '_')
|
|
45
|
-
|
|
46
|
-
# Nombre del archivo con el prefijo "simbols_"
|
|
47
|
-
category_file_name = f'tests/files/simbols_{category_name_safe}.json'
|
|
48
|
-
|
|
49
|
-
# Guardar la categoría y sus valores en un archivo JSON
|
|
50
|
-
category_data = {
|
|
51
|
-
"nom": category_name,
|
|
52
|
-
"descripcio": category["descripcio"],
|
|
53
|
-
"valors": category["valors"]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
with open(category_file_name, 'w', encoding='utf-8') as f:
|
|
57
|
-
json.dump(category_data, f, ensure_ascii=False, indent=4)
|
|
58
|
-
|
|
59
|
-
# Asegurarse de que se hayan creado los archivos correctamente
|
|
60
|
-
for category in simbolos_data:
|
|
61
|
-
if "valors" in category:
|
|
62
|
-
category_name = category['nom']
|
|
63
|
-
|
|
64
|
-
# Reemplazar los espacios por guiones bajos también al verificar
|
|
65
|
-
category_name_safe = category_name.replace(' ', '_')
|
|
66
|
-
|
|
67
|
-
category_file_name = f'tests/files/simbols_{category_name_safe}.json'
|
|
68
|
-
assert os.path.exists(category_file_name), f"File for category {category_name} was not created"
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
import json
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from meteocatpy.symbols import MeteocatSymbols
|
|
6
|
+
|
|
7
|
+
# Cargar variables desde el archivo .env
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
# Obtener los valores del archivo .env
|
|
11
|
+
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
+
|
|
13
|
+
# Asegúrate de que las variables estén definidas
|
|
14
|
+
assert API_KEY, "API Key is required"
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_simbols():
|
|
18
|
+
# Crear una instancia de MeteocatSymbols con la API Key
|
|
19
|
+
symbols_client = MeteocatSymbols(API_KEY)
|
|
20
|
+
|
|
21
|
+
# Obtener los símbolos
|
|
22
|
+
simbolos_data = await symbols_client.fetch_symbols()
|
|
23
|
+
|
|
24
|
+
# Verificar la estructura de los datos obtenidos
|
|
25
|
+
print("Estructura de los datos obtenidos:")
|
|
26
|
+
print(simbolos_data) # Esto te mostrará si realmente es una lista de categorías
|
|
27
|
+
|
|
28
|
+
# Crear la carpeta si no existe
|
|
29
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
30
|
+
|
|
31
|
+
# Guardar el JSON completo original
|
|
32
|
+
with open('tests/files/simbols.json', 'w', encoding='utf-8') as f:
|
|
33
|
+
json.dump(simbolos_data, f, ensure_ascii=False, indent=4)
|
|
34
|
+
|
|
35
|
+
# Verificar que los símbolos no estén vacíos
|
|
36
|
+
assert simbolos_data, "Simbols data is empty"
|
|
37
|
+
|
|
38
|
+
# Iterar sobre las categorías y guardar cada una en su propio archivo
|
|
39
|
+
for category in simbolos_data:
|
|
40
|
+
if "valors" in category: # Asegurarse de que tenga "valors"
|
|
41
|
+
category_name = category['nom'] # Nombre de la categoría (e.g., "cel", "mar", etc.)
|
|
42
|
+
|
|
43
|
+
# Reemplazar los espacios por guiones bajos en el nombre de la categoría
|
|
44
|
+
category_name_safe = category_name.replace(' ', '_')
|
|
45
|
+
|
|
46
|
+
# Nombre del archivo con el prefijo "simbols_"
|
|
47
|
+
category_file_name = f'tests/files/simbols_{category_name_safe}.json'
|
|
48
|
+
|
|
49
|
+
# Guardar la categoría y sus valores en un archivo JSON
|
|
50
|
+
category_data = {
|
|
51
|
+
"nom": category_name,
|
|
52
|
+
"descripcio": category["descripcio"],
|
|
53
|
+
"valors": category["valors"]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
with open(category_file_name, 'w', encoding='utf-8') as f:
|
|
57
|
+
json.dump(category_data, f, ensure_ascii=False, indent=4)
|
|
58
|
+
|
|
59
|
+
# Asegurarse de que se hayan creado los archivos correctamente
|
|
60
|
+
for category in simbolos_data:
|
|
61
|
+
if "valors" in category:
|
|
62
|
+
category_name = category['nom']
|
|
63
|
+
|
|
64
|
+
# Reemplazar los espacios por guiones bajos también al verificar
|
|
65
|
+
category_name_safe = category_name.replace(' ', '_')
|
|
66
|
+
|
|
67
|
+
category_file_name = f'tests/files/simbols_{category_name_safe}.json'
|
|
68
|
+
assert os.path.exists(category_file_name), f"File for category {category_name} was not created"
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
import json
|
|
4
|
-
from dotenv import load_dotenv
|
|
5
|
-
from meteocatpy.town import MeteocatTown
|
|
6
|
-
|
|
7
|
-
# Cargar variables desde el archivo .env
|
|
8
|
-
load_dotenv()
|
|
9
|
-
|
|
10
|
-
# Obtener los valores del archivo .env
|
|
11
|
-
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
-
|
|
13
|
-
# Asegúrate de que las variables estén definidas
|
|
14
|
-
assert API_KEY, "API Key is required"
|
|
15
|
-
|
|
16
|
-
@pytest.mark.asyncio
|
|
17
|
-
async def test_municipis():
|
|
18
|
-
# Crear una instancia de MeteocatTown con la API Key
|
|
19
|
-
town_client = MeteocatTown(API_KEY)
|
|
20
|
-
|
|
21
|
-
# Obtener los municipios
|
|
22
|
-
municipios_data = await town_client.get_municipis()
|
|
23
|
-
|
|
24
|
-
# Crear la carpeta si no existe
|
|
25
|
-
os.makedirs('tests/files', exist_ok=True)
|
|
26
|
-
|
|
27
|
-
# Guardar los datos de los municipios en un archivo JSON
|
|
28
|
-
with open('tests/files/municipis.json', 'w', encoding='utf-8') as f:
|
|
29
|
-
json.dump(municipios_data, f, ensure_ascii=False, indent=4)
|
|
30
|
-
|
|
31
|
-
# Verificar que los municipios no estén vacíos
|
|
32
|
-
assert municipios_data, "Municipis data is empty"
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
import json
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from meteocatpy.town import MeteocatTown
|
|
6
|
+
|
|
7
|
+
# Cargar variables desde el archivo .env
|
|
8
|
+
load_dotenv()
|
|
9
|
+
|
|
10
|
+
# Obtener los valores del archivo .env
|
|
11
|
+
API_KEY = os.getenv("METEOCAT_API_KEY")
|
|
12
|
+
|
|
13
|
+
# Asegúrate de que las variables estén definidas
|
|
14
|
+
assert API_KEY, "API Key is required"
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_municipis():
|
|
18
|
+
# Crear una instancia de MeteocatTown con la API Key
|
|
19
|
+
town_client = MeteocatTown(API_KEY)
|
|
20
|
+
|
|
21
|
+
# Obtener los municipios
|
|
22
|
+
municipios_data = await town_client.get_municipis()
|
|
23
|
+
|
|
24
|
+
# Crear la carpeta si no existe
|
|
25
|
+
os.makedirs('tests/files', exist_ok=True)
|
|
26
|
+
|
|
27
|
+
# Guardar los datos de los municipios en un archivo JSON
|
|
28
|
+
with open('tests/files/municipis.json', 'w', encoding='utf-8') as f:
|
|
29
|
+
json.dump(municipios_data, f, ensure_ascii=False, indent=4)
|
|
30
|
+
|
|
31
|
+
# Verificar que los municipios no estén vacíos
|
|
32
|
+
assert municipios_data, "Municipis data is empty"
|