Example #1
0
    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"
Example #2
0
 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"
     )
Example #3
0
 def test_urlsafe():
     urlsafe = base64.urlsafe_b64encode(b"123")
     cursor = _datastore_query.Cursor(b"123")
     assert cursor.urlsafe() == urlsafe
Example #4
0
 def test_to_websafe_string():
     urlsafe = base64.urlsafe_b64encode(b"123")
     cursor = _datastore_query.Cursor(b"123")
     assert cursor.to_websafe_string() == urlsafe
Example #5
0
 def test_constructor_cursor_and_urlsafe():
     with pytest.raises(TypeError):
         _datastore_query.Cursor(b"123", urlsafe="what?")
Example #6
0
 def test_constructor():
     cursor = _datastore_query.Cursor(b"123")
     assert cursor.cursor == b"123"