Beispiel #1
0
    def test_to_repr():
        lat = 49.2827
        lon = 123.1207
        latlng = LatLng(lat, lon)

        r = latlng.to_repr()

        assert r['latitude'] == lat
        assert r['longitude'] == lon
Beispiel #2
0
    def test_from_repr(lat_lng):
        original_latlng = lat_lng
        data = {
            'latitude': original_latlng.lat,
            'longitude': original_latlng.lon,
        }

        output_order = LatLng.from_repr(data)

        assert output_order == original_latlng
async def test_geo_point_value(creds: str, kind: str, project: str) -> None:
    key = Key(project, [PathElement(kind)])

    async with Session(timeout=10) as s:
        ds = Datastore(project=project, service_file=creds, session=s)

        allocatedKeys = await ds.allocateIds([key], session=s)
        await ds.reserveIds(allocatedKeys, session=s)

        props_insert = {'location': LatLng(49.2827, 123.1207)}
        await ds.insert(allocatedKeys[0], props_insert, session=s)
        actual = await ds.lookup([allocatedKeys[0]], session=s)
        assert actual['found'][0].entity.properties == props_insert
Beispiel #4
0
 def lat_lng() -> LatLng:
     return LatLng(49.2827, 123.1207)