Example #1
0
def api():
    """Create shared XYZ Token API instance as a pytest fixture."""
    try:
        api = TokenApi(config=XYZConfig.from_default())
    except AuthenticationError:
        api = TokenApi()
        warnings.warn("Ignoring invalid credentials, creating TokenApi "
                      "instance without. Access limitations may apply.")
    return api
def test_default_config():
    """Test default config."""
    xyzconfig = XYZConfig.from_default()
    assert xyzconfig.config["credentials"]["XYZ_TOKEN"] == os.environ.get(
        "XYZ_TOKEN")
    assert xyzconfig.config["credentials"]["HERE_USER"] == os.environ.get(
        "HERE_USER")
    assert xyzconfig.config["credentials"]["HERE_PASSWORD"] == os.environ.get(
        "HERE_PASSWORD")
    assert xyzconfig.config["url"] == "https://xyz.api.here.com"
    assert (xyzconfig.config["http_headers"]["Authorization"] ==
            f"Bearer {os.environ.get('XYZ_TOKEN')}")
    assert (xyzconfig.config["http_headers"]["Content-Type"] ==
            "application/geo+json")
Example #3
0
def point_space_id():
    """Create shared XYZ space with Chicago Parks data."""
    api = HubApi(config=XYZConfig.from_default())
    # setup, create temporary space
    res = api.post_space(
        data={
            "title": "Testing xyzspaces",
            "description": "Temporary space containing Chicago Parks data",
        })
    space_id = res["id"]
    gj_chicago_parks = get_chicago_parks_data()
    sleep(0.5)
    api.put_space_features(space_id=space_id, data=gj_chicago_parks)
    yield space_id

    # now teardown (delete temporary space)
    api.delete_space(space_id=space_id)
Example #4
0
def space_id():
    """Create shared XYZ space with countries data as a pytest fixture."""
    api = HubApi(config=XYZConfig.from_default())

    # setup, create temporary space
    res = api.post_space(
        data={
            "title": "Testing xyzspaces",
            "description": "Temporary space containing countries data.",
        })
    space_id = res["id"]

    # add features to space
    gj_countries = get_countries_data()
    sleep(0.5)
    api.put_space_features(space_id=space_id, data=gj_countries)

    yield space_id

    # now teardown (delete temporary space)
    api.delete_space(space_id=space_id)
Example #5
0
def api():
    """Create shared XYZ Project Api instance as a pytest fixture."""
    api = ProjectApi(config=XYZConfig.from_default())
    return api