def walk_spaces():
    """Walk over all spaces and do something to them..."""
    # Uses credentials from XYZ_TOKEN env. variable.
    api = HubApi()

    for i, space in enumerate(api.get_spaces()):
        id, title = space["id"], space["title"]
        count = api.get_space_count(space_id=id)["count"]
        # if title.find("Testing") >= 0:
        # if count > 0:
        #     api.delete_space(space_id=id)
        print(i, id, count, title)
示例#2
0
def point_space_id():
    """Create shared XYZ space with Chicago Parks data."""
    api = HubApi(credentials=XYZ_TOKEN)
    # 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)
示例#3
0
def space_id():
    """Create shared XYZ space with countries data as a pytest fixture."""
    api = HubApi(credentials=XYZ_TOKEN)

    # 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)
示例#4
0
def api():
    """Create shared XYZ Hub Api instance as a pytest fixture."""
    api = HubApi(credentials=XYZ_TOKEN)
    return api
示例#5
0
def test_get_space_statistics_env_token(space_id):
    """Get space statistics with default token directly from environment."""
    my_api = HubApi()
    stats = my_api.get_space_statistics(space_id=space_id)
    assert stats["type"] == "StatisticsResponse"
示例#6
0
def api():
    """Create shared XYZ Hub Api instance as a pytest fixture."""
    api = HubApi(config=XYZConfig.from_default())
    return api