#13 stops store and trip store tests
This commit is contained in:
parent
64fe8b5571
commit
45e2426b35
|
|
@ -1 +1,2 @@
|
||||||
recursive-include amarillo/static/ *
|
recursive-include amarillo/static/ *
|
||||||
|
recursive-include amarillo/app/tests/ *
|
||||||
0
amarillo/app/tests/__init__.py
Normal file
0
amarillo/app/tests/__init__.py
Normal file
5
amarillo/app/tests/stops.csv
Normal file
5
amarillo/app/tests/stops.csv
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
stop_id;stop_code;stop_lat;stop_lon;stop_name
|
||||||
|
mfdz:x;x;52.11901;14.2;Stop x
|
||||||
|
mfdz:y;y;53.1;14.01;Stop y
|
||||||
|
mfdz:z;z;54.11;14.0;Stop z
|
||||||
|
mfdz:Ang001;Ang001;53.11901;14.015776;Mitfahrbank Biesenbrow
|
||||||
|
39
amarillo/app/tests/stops.json
Normal file
39
amarillo/app/tests/stops.json
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"pointsOfInterest": [
|
||||||
|
{
|
||||||
|
"id": "14622",
|
||||||
|
"externalId": "bbnavi:12073:0001",
|
||||||
|
"name": "Parkbank",
|
||||||
|
"description": "Parkbank",
|
||||||
|
"dataProvider": {
|
||||||
|
"id": "1",
|
||||||
|
"name": "Administrator"
|
||||||
|
},
|
||||||
|
"addresses": [
|
||||||
|
{
|
||||||
|
"street": "Hauptstrasse",
|
||||||
|
"city": "Wittenberge",
|
||||||
|
"zip": "12345",
|
||||||
|
"geoLocation": {
|
||||||
|
"latitude": 52.9932971109789,
|
||||||
|
"longitude": 11.767383582547
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"openStreetMap": {
|
||||||
|
"capacity": 112,
|
||||||
|
"capacityCharging": "2",
|
||||||
|
"capacityDisabled": "",
|
||||||
|
"fee": "No",
|
||||||
|
"lit": "Yes",
|
||||||
|
"parking": "",
|
||||||
|
"shelter": "No",
|
||||||
|
"surface": "",
|
||||||
|
"utilization": "",
|
||||||
|
"website": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
24
amarillo/app/tests/test_stops_store.py
Normal file
24
amarillo/app/tests/test_stops_store.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
from amarillo.app.services import stops
|
||||||
|
from amarillo.app.models.Carpool import StopTime
|
||||||
|
|
||||||
|
def test_load_stops_from_file():
|
||||||
|
store = stops.StopsStore([{"url": "amarillo/app/tests/stops.csv", "vicinity": 50}])
|
||||||
|
store.load_stop_sources()
|
||||||
|
assert len(store.stopsDataFrames[0]['stops']) > 0
|
||||||
|
|
||||||
|
def test_load_csv_stops_from_web_():
|
||||||
|
store = stops.StopsStore([{"url": "https://data.mfdz.de/mfdz/stops/custom.csv", "vicinity": 50}])
|
||||||
|
store.load_stop_sources()
|
||||||
|
assert len(store.stopsDataFrames[0]['stops']) > 0
|
||||||
|
|
||||||
|
def test_load_geojson_stops_from_web_():
|
||||||
|
store = stops.StopsStore([{"url": "https://datahub.bbnavi.de/export/rideshare_points.geojson", "vicinity": 50}])
|
||||||
|
store.load_stop_sources()
|
||||||
|
assert len(store.stopsDataFrames[0]['stops']) > 0
|
||||||
|
|
||||||
|
def test_find_closest_stop():
|
||||||
|
store = stops.StopsStore([{"url": "amarillo/app/tests/stops.csv", "vicinity": 50}])
|
||||||
|
store.load_stop_sources()
|
||||||
|
carpool_stop = StopTime(name="start", lat=53.1191, lon=14.01577)
|
||||||
|
stop = store.find_closest_stop(carpool_stop, 1000)
|
||||||
|
assert stop.name=='Mitfahrbank Biesenbrow'
|
||||||
23
amarillo/app/tests/test_trip_store.py
Normal file
23
amarillo/app/tests/test_trip_store.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
from amarillo.app.tests.sampledata import cp1, carpool_repeating
|
||||||
|
from amarillo.app.services.trips import TripStore
|
||||||
|
from amarillo.app.services.stops import StopsStore
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def test_trip_store_put_one_time_carpool():
|
||||||
|
trip_store = TripStore(StopsStore())
|
||||||
|
|
||||||
|
t = trip_store.put_carpool(cp1)
|
||||||
|
assert t != None
|
||||||
|
assert len(t.stop_times) >= 2
|
||||||
|
assert t.stop_times[0].stop_id == 'mfdz:12073:001'
|
||||||
|
assert t.stop_times[-1].stop_id == 'de:12073:900340137::3'
|
||||||
|
|
||||||
|
def test_trip_store_put_repeating_carpool():
|
||||||
|
trip_store = TripStore(StopsStore())
|
||||||
|
|
||||||
|
t = trip_store.put_carpool(carpool_repeating)
|
||||||
|
assert t != None
|
||||||
|
assert len(t.stop_times) >= 2
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "amarillo-core"
|
name = "amarillo-core"
|
||||||
version = "0.0.9"
|
version = "0.0.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastapi[all]==0.104.0",
|
"fastapi[all]==0.104.0",
|
||||||
"geopandas==0.14",
|
"geopandas==0.14",
|
||||||
|
|
@ -11,6 +11,7 @@ dependencies = [
|
||||||
"requests==2.31.0",
|
"requests==2.31.0",
|
||||||
"pyproj==3.6.1",
|
"pyproj==3.6.1",
|
||||||
"geojson-pydantic==1.0.1",
|
"geojson-pydantic==1.0.1",
|
||||||
|
"pytest",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools.packages]
|
[tool.setuptools.packages]
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,4 @@ starlette
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
pyproj==3.6.1
|
pyproj==3.6.1
|
||||||
geojson-pydantic==1.0.1
|
geojson-pydantic==1.0.1
|
||||||
|
pytest
|
||||||
Loading…
Reference in a new issue