def test_eventually_consistent_legacy(runstate): options = _api._get_read_options( {"read_policy": _api.EVENTUAL_CONSISTENCY} ) assert options == datastore_pb2.ReadOptions( read_consistency=datastore_pb2.ReadOptions.EVENTUAL )
def test_eventually_consistent_with_transaction(runstate): with pytest.raises(ValueError): _api._get_read_options( {"read_consistency": _api.EVENTUAL, "transaction": b"txfoo"} )
def test_eventually_consistent(runstate): options = _api._get_read_options({"read_consistency": _api.EVENTUAL}) assert options == datastore_pb2.ReadOptions( read_consistency=datastore_pb2.ReadOptions.EVENTUAL )
def test_args_override_transaction(runstate): runstate.transaction = b"txfoo" options = _api._get_read_options({"transaction": b"txbar"}) assert options == datastore_pb2.ReadOptions(transaction=b"txbar")
def test_no_args_transaction(runstate): runstate.transaction = b"txfoo" options = _api._get_read_options({}) assert options == datastore_pb2.ReadOptions(transaction=b"txfoo")
def test_no_args_no_transaction(runstate): assert _api._get_read_options({}) == datastore_pb2.ReadOptions()
def test_args_override_transaction(context): with context.new(transaction=b"txfoo"): options = _api._get_read_options({"transaction": b"txbar"}) assert options == datastore_pb2.ReadOptions(transaction=b"txbar")
def test_no_args_transaction(context): with context.new(transaction=b"txfoo"): options = _api._get_read_options({}) assert options == datastore_pb2.ReadOptions(transaction=b"txfoo")