def test_constructor_w_read_policy(): options = _options.ReadOptions(read_policy=_datastore_api.EVENTUAL_CONSISTENCY) assert options == _options.ReadOptions(read_consistency=_datastore_api.EVENTUAL)
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, )
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")
def test_no_args_no_transaction(): assert ( _api.get_read_options(_options.ReadOptions()) == datastore_pb2.ReadOptions() )
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()
def test_eventually_consistent_with_transaction(): with pytest.raises(ValueError): _api.get_read_options( _options.ReadOptions(read_consistency=_api.EVENTUAL, transaction=b"txfoo"))
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)