예제 #1
0
def test_get_bike_point_by_id_error():
    tflapi = TflApi(app_key)

    with pytest.raises(TflApiError):
        tflapi.get_bike_point_by_id(2)
예제 #2
0
파일: example.py 프로젝트: jltwheeler/tflpy
import os

from dotenv import load_dotenv

from tflpy import TflApi, BaseMap
from tflpy.utils import create_geojson_feature_points

load_dotenv()
app_key = os.getenv("APP_KEY")

tflapi = TflApi(app_key)

bike_points = tflapi.get_bike_points()
data = [(bike_point["lon"], bike_point["lat"]) for bike_point in bike_points]
properties = [{"id": bike_point["id"]} for bike_point in bike_points]

bm = BaseMap()
bm.add_data(create_geojson_feature_points(data, properties))
bm.save_figure()
예제 #3
0
def test_get_bike_points():
    tflapi = TflApi(app_key)

    assert len(tflapi.get_bike_points()) > 0
예제 #4
0
def test_get_bike_point_by_id():
    tflapi = TflApi(app_key)

    assert len(tflapi.get_bike_point_by_id("BikePoints_1")) > 0
예제 #5
0
def test_get_air_quality():
    tflapi = TflApi(app_key)

    assert len(tflapi.get_air_quality()) > 0
예제 #6
0
def test_get_accidents_by_year_error():
    tflapi = TflApi(app_key)

    with pytest.raises(TflApiError):
        tflapi.get_accidents_by_year(2500)
예제 #7
0
def test_get_accidents_by_year():
    tflapi = TflApi(app_key)

    assert len(tflapi.get_accidents_by_year(2018)) > 0
예제 #8
0
def test_invalid_app_key():
    with pytest.raises(TflApiError):
        TflApi("invalidkey")
예제 #9
0
def test_valid_app_key():
    tflapi = TflApi()
    assert tflapi.init_resp.status_code == 200