コード例 #1
0
def activity_log_space():
    """Create a new space supporting activity log."""
    listeners = {
        "id": "activity-log",
        "params": {
            "states": 5,
            "storageMode": "DIFF_ONLY",
            "writeInvalidatedAt": "true",
        },
        "eventTypes": ["ModifySpaceEvent.request"],
    }
    space = Space.new(
        title="Activity-Log Test",
        description="A test space for Activity-Log",
        enable_uuid=True,
        listeners=listeners,
    )
    sleep(0.5)
    yield space

    # now teardown (delete temporary space and activity log space)
    activity_log_spaceid = space.info["listeners"]["activity-log-writer"][0][
        "params"
    ]["spaceId"]
    space2 = Space.from_id(activity_log_spaceid)
    space.delete()
    space2.delete()
コード例 #2
0
def test_new_space():
    """Test create and delete a new space."""
    # create space
    space = Space.new(title="Foo", description="Bar")
    assert space.info["title"] == "Foo"
    space_id = space.info["id"]
    # delete space
    space.delete()
    assert space.info == {}
    with pytest.raises(ApiError):
        space.read(id=space_id)
コード例 #3
0
def shared_space():
    """Create a new shared space."""
    space = Space.new(
        title="test shared space", description="test shared space", shared=True
    )

    sleep(0.5)
    yield space

    # now teardown (delete temporary space)
    space.delete()
コード例 #4
0
ファイル: conftest.py プロジェクト: sackh/xyz-spaces-python
def schema_validation_space():
    """Create a space with schema validation."""
    schema = (
        '{"definitions":{},"$schema":"http://json-schema.org/draft-07/schema#",'
        '"$id":"http://example.com/root.json","type":"object",'
        '"title":"TheRootSchema","required":["geometry","type","properties"]}')
    space = Space.new(
        title="test schema validation space",
        description="test schema validation space",
        schema=schema,
    )
    yield space

    # now teardown (delete temporary space)
    space.delete()
コード例 #5
0
def test_create_delete_1(api):
    """Test create and delete a new space."""
    # create space
    space = Space.new(title="Foo", description="Bar")
    sleep(0.5)
    assert space.info["title"] == "Foo"
    assert "id" in space.info

    # add features
    _ = space.add_features(features=gj_countries)
    # get feature
    _ = space.get_feature(feature_id="FRA")

    # delete space
    space.delete()
    assert space.info == {}
コード例 #6
0
def test_new_space():
    """Test create and delete a new space."""
    # create space
    space = Space.new(title="Foo", description="Bar")
    sleep(0.5)
    space_info = space.info
    assert space_info["title"] == "Foo"
    assert "shared" not in space_info
    assert not space.isshared()
    space_id = space.info["id"]
    # delete space
    space.delete()
    sleep(1)
    assert space.info == {}
    with pytest.raises(ApiError):
        space.read(id=space_id)
コード例 #7
0
def test_create_delete_1(api):
    """Test create and delete a new space."""
    # create space
    space = Space.new(title="Foo", description="Bar")
    assert space.info["title"] == "Foo"
    print("created", space.info)
    id = space.info["id"]
    assert "id" in space.info

    # add features
    res = space.add_features(features=gj_countries)
    # get feature
    res = space.get_feature(feature_id="FRA")
    print(res)

    # delete space
    space.delete()
    print("deleted", id)
    assert space.info == {}
コード例 #8
0
def large_data_space():
    """Create a new large data space."""
    space = Space.new(
        title="test large data space",
        description="test large data space",
        shared=True,
    )
    path = Path(__file__).parent.parent / "data" / "large_data.geojson"

    with open(path) as json_file:
        data = json.load(json_file)

    space.add_features(data, features_size=5000, chunk_size=2)

    sleep(0.5)
    yield space

    # now teardown (delete temporary space)
    space.delete()