def test_constructor_urlsafe(): urlsafe = base64.urlsafe_b64encode(b"123") cursor = _datastore_query.Cursor(urlsafe=urlsafe) assert cursor.cursor == b"123" cursor = _datastore_query.Cursor(urlsafe=urlsafe.decode("ascii")) assert cursor.cursor == b"123"
def test_end_cursor(): query = query_module.QueryOptions( end_cursor=_datastore_query.Cursor(b"abc") ) assert _datastore_query._query_to_protobuf(query) == query_pb2.Query( end_cursor=b"abc" )
def test_urlsafe(): urlsafe = base64.urlsafe_b64encode(b"123") cursor = _datastore_query.Cursor(b"123") assert cursor.urlsafe() == urlsafe
def test_to_websafe_string(): urlsafe = base64.urlsafe_b64encode(b"123") cursor = _datastore_query.Cursor(b"123") assert cursor.to_websafe_string() == urlsafe
def test_constructor_cursor_and_urlsafe(): with pytest.raises(TypeError): _datastore_query.Cursor(b"123", urlsafe="what?")
def test_constructor(): cursor = _datastore_query.Cursor(b"123") assert cursor.cursor == b"123"