Esempio n. 1
0
 def test_constructor_w_read_policy():
     options = _options.ReadOptions(read_policy=_datastore_api.EVENTUAL_CONSISTENCY)
     assert options == _options.ReadOptions(read_consistency=_datastore_api.EVENTUAL)
Esempio n. 2
0
 def test_constructor_w_read_policy_and_read_consistency():
     with pytest.raises(TypeError):
         _options.ReadOptions(
             read_policy=_datastore_api.EVENTUAL_CONSISTENCY,
             read_consistency=_datastore_api.EVENTUAL,
         )
Esempio n. 3
0
 def test_args_override_transaction(context):
     with context.new(transaction=b"txfoo").use():
         options = _api.get_read_options(
             _options.ReadOptions(transaction=b"txbar")
         )
         assert options == datastore_pb2.ReadOptions(transaction=b"txbar")
Esempio n. 4
0
 def test_no_args_no_transaction():
     assert (
         _api.get_read_options(_options.ReadOptions())
         == datastore_pb2.ReadOptions()
     )
Esempio n. 5
0
 def test_it_no_global_cache_or_datastore(in_context):
     with pytest.raises(TypeError):
         _api.lookup(
             _mock_key("foo"), _options.ReadOptions(use_datastore=False)
         ).result()
Esempio n. 6
0
 def test_eventually_consistent_with_transaction():
     with pytest.raises(ValueError):
         _api.get_read_options(
             _options.ReadOptions(read_consistency=_api.EVENTUAL,
                                  transaction=b"txfoo"))
Esempio n. 7
0
 def test_eventually_consistent():
     options = _api.get_read_options(
         _options.ReadOptions(read_consistency=_api.EVENTUAL))
     assert options == datastore_pb2.ReadOptions(
         read_consistency=datastore_pb2.ReadOptions.EVENTUAL)