diff --git a/docs/index.rst b/docs/index.rst index 1da370fc064810a569fe57171d2f24906353842a..66cc0db3343fda9da34b8c2ac635dd088aa4ba1e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -115,20 +115,19 @@ database:: >>> async def go(app): ... session = await app.session() - ... async with session: - ... leif = Person() - ... leif.name = 'Leif' - ... leif.age = 28 - ... jon = Person() - ... jon.name = 'Jonathan' - ... works_with = Knows(leif, jon) - ... session.add(leif, jon, works_with) - ... await session.flush() - ... result = await session.g.E(works_with.id).one_or_none() - ... assert result is works_with - ... people = await session.traversal(Person).all() # element class based traversal source - ... async for person in people: - ... print(person) + ... leif = Person() + ... leif.name = 'Leif' + ... leif.age = 28 + ... jon = Person() + ... jon.name = 'Jonathan' + ... works_with = Knows(leif, jon) + ... session.add(leif, jon, works_with) + ... await session.flush() + ... result = await session.g.E(works_with.id).one_or_none() + ... assert result is works_with + ... people = await session.traversal(Person).all() # element class based traversal source + ... async for person in people: + ... print(person) >>> loop.run_until_complete(go(app)) diff --git a/goblin/app.py b/goblin/app.py index e2927176d133327dc7235788a392652508fef4c4..1b2eec2f82b44ddd8240215a5cd2fa33ec3508c4 100644 --- a/goblin/app.py +++ b/goblin/app.py @@ -111,10 +111,7 @@ class Goblin: :returns: :py:class:`Session<goblin.session.Session>` object """ - if not use_session: - conn = await self._cluster.connect() - else: - conn = await self._cluster.get_connection() + conn = await self._cluster.connect() transactions = await self.supports_transactions() return session.Session(self, conn, diff --git a/goblin/session.py b/goblin/session.py index b22644d695b8d55205dbf2a84a7a98d959354df5..d13599975ddf2d0244828c7524f235608d514b45 100644 --- a/goblin/session.py +++ b/goblin/session.py @@ -30,7 +30,7 @@ from goblin.element import GenericVertex logger = logging.getLogger(__name__) -class Session(connection.AbstractConnection): +class Session: """ Provides the main API for interacting with the database. Does not necessarily correpsond to a database session. Don't instantiate directly, @@ -72,19 +72,6 @@ class Session(connection.AbstractConnection): def current(self): return self._current - async def __aenter__(self): - return self - - async def __aexit__(self, exc_type, exc, tb): - self.close() - - def close(self): - """ - """ - # await self.conn.close() - self._conn = None - self._app = None - # Traversal API @property def g(self): diff --git a/tests/test_session.py b/tests/test_session.py index 55e07eb15ffd42de88f7fa19365b335c6d5e0e06..25dc2886854cc809005abf65970c71c0a9a300c9 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -23,222 +23,192 @@ from goblin import element from goblin.traversal import bindprop -# Session closing behaviour is undetermined -# @pytest.mark.asyncio -# async def test_session_close(session): -# assert not session.conn.closed -# await session.close() -# assert session.conn.closed - - -# @pytest.mark.asyncio -# async def test_session_ctxt_mngr(app): -# session = await app.session() -# async with session: -# assert not session.conn.closed -# assert session.conn.closed -# await app.close() - - class TestCreationApi: @pytest.mark.asyncio async def test_create_vertex(self, app, person_class): session = await app.session() - async with session: - jon = person_class() - jon.name = 'jonathan' - jon.age = 38 - leif = person_class() - leif.name = 'leifur' - leif.age = 28 - session.add(jon, leif) - assert not hasattr(jon, 'id') - assert not hasattr(leif, 'id') - await session.flush() - assert hasattr(jon, 'id') - assert session.current[jon.id] is jon - assert jon.name == 'jonathan' - assert jon.age == 38 - assert hasattr(leif, 'id') - assert session.current[leif.id] is leif - assert leif.name == 'leifur' - assert leif.age == 28 + jon = person_class() + jon.name = 'jonathan' + jon.age = 38 + leif = person_class() + leif.name = 'leifur' + leif.age = 28 + session.add(jon, leif) + assert not hasattr(jon, 'id') + assert not hasattr(leif, 'id') + await session.flush() + assert hasattr(jon, 'id') + assert session.current[jon.id] is jon + assert jon.name == 'jonathan' + assert jon.age == 38 + assert hasattr(leif, 'id') + assert session.current[leif.id] is leif + assert leif.name == 'leifur' + assert leif.age == 28 await app.close() @pytest.mark.asyncio async def test_create_edge(self, app, person_class, place_class, lives_in_class): session = await app.session() - async with session: - jon = person_class() - jon.name = 'jonathan' - jon.age = 38 - montreal = place_class() - montreal.name = 'Montreal' - lives_in = lives_in_class(jon, montreal) - session.add(jon, montreal, lives_in) - await session.flush() - assert hasattr(lives_in, 'id') - assert session.current[lives_in.id] is lives_in - assert lives_in.source is jon - assert lives_in.target is montreal - assert lives_in.source.__label__ == 'person' - assert lives_in.target.__label__ == 'place' + jon = person_class() + jon.name = 'jonathan' + jon.age = 38 + montreal = place_class() + montreal.name = 'Montreal' + lives_in = lives_in_class(jon, montreal) + session.add(jon, montreal, lives_in) + await session.flush() + assert hasattr(lives_in, 'id') + assert session.current[lives_in.id] is lives_in + assert lives_in.source is jon + assert lives_in.target is montreal + assert lives_in.source.__label__ == 'person' + assert lives_in.target.__label__ == 'place' await app.close() @pytest.mark.asyncio async def test_create_edge_no_source(self, app, lives_in, person): session = await app.session() - async with session: - lives_in.source = person - with pytest.raises(Exception): - await session.save(lives_in) + lives_in.source = person + with pytest.raises(Exception): + await session.save(lives_in) await app.close() @pytest.mark.asyncio async def test_create_edge_no_target(self, app, lives_in, place): session = await app.session() - async with session: - lives_in.target = place - with pytest.raises(Exception): - await session.save(lives_in) + lives_in.target = place + with pytest.raises(Exception): + await session.save(lives_in) await app.close() @pytest.mark.asyncio async def test_create_edge_no_source_target(self, app, lives_in): session = await app.session() - async with session: - with pytest.raises(Exception): - await session.save(lives_in) + with pytest.raises(Exception): + await session.save(lives_in) await app.close() @pytest.mark.asyncio async def test_get_vertex(self, app, person_class): session = await app.session() - async with session: - jon = person_class() - jon.name = 'jonathan' - jon.age = 38 - await session.save(jon) - jid = jon.id - result = await session.get_vertex(jon) - assert result.id == jid - assert result is jon + jon = person_class() + jon.name = 'jonathan' + jon.age = 38 + await session.save(jon) + jid = jon.id + result = await session.get_vertex(jon) + assert result.id == jid + assert result is jon await app.close() @pytest.mark.asyncio async def test_get_edge(self, app, person_class, place_class, lives_in_class): session = await app.session() - async with session: - jon = person_class() - jon.name = 'jonathan' - jon.age = 38 - montreal = place_class() - montreal.name = 'Montreal' - lives_in = lives_in_class(jon, montreal) - session.add(jon, montreal, lives_in) - await session.flush() - lid = lives_in.id - result = await session.get_edge(lives_in) - assert result.id == lid - assert result is lives_in + jon = person_class() + jon.name = 'jonathan' + jon.age = 38 + montreal = place_class() + montreal.name = 'Montreal' + lives_in = lives_in_class(jon, montreal) + session.add(jon, montreal, lives_in) + await session.flush() + lid = lives_in.id + result = await session.get_edge(lives_in) + assert result.id == lid + assert result is lives_in await app.close() @pytest.mark.asyncio async def test_get_vertex_doesnt_exist(self, app, person): session = await app.session() - async with session: - person._id = 1000000000000000000000000000000000000000000000 - result = await session.get_vertex(person) - assert not result + person._id = 1000000000000000000000000000000000000000000000 + result = await session.get_vertex(person) + assert not result await app.close() @pytest.mark.asyncio async def test_get_edge_doesnt_exist(self, app, knows, person_class): session = await app.session() - async with session: - jon = person_class() - leif = person_class() - works_with = knows - works_with.source = jon - works_with.target = leif - works_with._id = 1000000000000000000000000000000000000000000000 - result = await session.get_edge(works_with) - assert not result + jon = person_class() + leif = person_class() + works_with = knows + works_with.source = jon + works_with.target = leif + works_with._id = 1000000000000000000000000000000000000000000000 + result = await session.get_edge(works_with) + assert not result await app.close() @pytest.mark.asyncio async def test_remove_vertex(self, app, person): session = await app.session() - async with session: - person.name = 'dave' - person.age = 35 - await session.save(person) - result = await session.g.V(person.id).one_or_none() - assert result is person - rid = result.id - await session.remove_vertex(person) - result = await session.g.V(rid).one_or_none() - assert not result + person.name = 'dave' + person.age = 35 + await session.save(person) + result = await session.g.V(person.id).one_or_none() + assert result is person + rid = result.id + await session.remove_vertex(person) + result = await session.g.V(rid).one_or_none() + assert not result await app.close() @pytest.mark.asyncio async def test_remove_edge(self, app, person_class, place_class, lives_in_class): session = await app.session() - async with session: - jon = person_class() - jon.name = 'jonathan' - jon.age = 38 - montreal = place_class() - montreal.name = 'Montreal' - lives_in = lives_in_class(jon, montreal) - session.add(jon, montreal, lives_in) - await session.flush() - result = await session.g.E(lives_in.id).one_or_none() - assert result is lives_in - rid = result.id - await session.remove_edge(lives_in) - result = await session.g.E(rid).one_or_none() - assert not result + jon = person_class() + jon.name = 'jonathan' + jon.age = 38 + montreal = place_class() + montreal.name = 'Montreal' + lives_in = lives_in_class(jon, montreal) + session.add(jon, montreal, lives_in) + await session.flush() + result = await session.g.E(lives_in.id).one_or_none() + assert result is lives_in + rid = result.id + await session.remove_edge(lives_in) + result = await session.g.E(rid).one_or_none() + assert not result await app.close() @pytest.mark.asyncio async def test_update_vertex(self, app, person): session = await app.session() - async with session: - person.name = 'dave' - person.age = 35 - result = await session.save(person) - assert result.name == 'dave' - assert result.age == 35 - person.name = 'david' - person.age = None - result = await session.save(person) - assert result is person - assert result.name == 'david' - assert not result.age + person.name = 'dave' + person.age = 35 + result = await session.save(person) + assert result.name == 'dave' + assert result.age == 35 + person.name = 'david' + person.age = None + result = await session.save(person) + assert result is person + assert result.name == 'david' + assert not result.age await app.close() @pytest.mark.asyncio async def test_update_edge(self, app, person_class, knows): session = await app.session() - async with session: - dave = person_class() - leif = person_class() - knows.source = dave - knows.target = leif - knows.notes = 'online' - session.add(dave, leif) - await session.flush() - result = await session.save(knows) - assert knows.notes == 'online' - knows.notes = None - result = await session.save(knows) - assert result is knows - assert not result.notes + dave = person_class() + leif = person_class() + knows.source = dave + knows.target = leif + knows.notes = 'online' + session.add(dave, leif) + await session.flush() + result = await session.save(knows) + assert knows.notes == 'online' + knows.notes = None + result = await session.save(knows) + assert result is knows + assert not result.notes await app.close() @@ -248,132 +218,121 @@ class TestTraversalApi: async def test_traversal_source_generation(self, app, person_class, knows_class): session = await app.session() - async with session: - traversal = session.traversal(person_class) - assert repr(traversal) == 'g.V().hasLabel("person")' - traversal = session.traversal(knows_class) - assert repr(traversal) == 'g.E().hasLabel("knows")' + traversal = session.traversal(person_class) + assert repr(traversal) == 'g.V().hasLabel("person")' + traversal = session.traversal(knows_class) + assert repr(traversal) == 'g.E().hasLabel("knows")' await app.close() @pytest.mark.asyncio async def test_all(self, app, person_class): session = await app.session() - async with session: - dave = person_class() - leif = person_class() - jon = person_class() - session.add(dave, leif, jon) - await session.flush() - resp = await session.traversal(person_class).all() - results = [] - async for msg in resp: - assert isinstance(msg, person_class) - results.append(msg) - assert len(results) > 2 + dave = person_class() + leif = person_class() + jon = person_class() + session.add(dave, leif, jon) + await session.flush() + resp = await session.traversal(person_class).all() + results = [] + async for msg in resp: + assert isinstance(msg, person_class) + results.append(msg) + assert len(results) > 2 await app.close() @pytest.mark.asyncio async def test_one_or_none_one(self, app, person_class): session = await app.session() - async with session: - dave = person_class() - leif = person_class() - jon = person_class() - session.add(dave, leif, jon) - await session.flush() - resp = await session.traversal(person_class).one_or_none() - assert isinstance(resp, person_class) + dave = person_class() + leif = person_class() + jon = person_class() + session.add(dave, leif, jon) + await session.flush() + resp = await session.traversal(person_class).one_or_none() + assert isinstance(resp, person_class) await app.close() @pytest.mark.asyncio async def test_traversal_bindprop(self, app, person_class): session = await app.session() - async with session: - itziri = person_class() - itziri.name = 'itziri' - result1 = await session.save(itziri) - bound_name = bindprop(person_class, 'name', 'itziri', binding='v1') - p1 = await session.traversal(person_class).has( - *bound_name).one_or_none() + itziri = person_class() + itziri.name = 'itziri' + result1 = await session.save(itziri) + bound_name = bindprop(person_class, 'name', 'itziri', binding='v1') + p1 = await session.traversal(person_class).has( + *bound_name).one_or_none() await app.close() @pytest.mark.asyncio async def test_one_or_none_none(self, app): session = await app.session() - async with session: - none = await session.g.V().hasLabel( - 'a very unlikey label').one_or_none() - assert not none + none = await session.g.V().hasLabel( + 'a very unlikey label').one_or_none() + assert not none await app.close() @pytest.mark.asyncio async def test_vertex_deserialization(self, app, person_class): session = await app.session() - async with session: - resp = await session.g.addV('person').property( - person_class.name, 'leif').property('place_of_birth', 'detroit').one_or_none() - assert isinstance(resp, person_class) - assert resp.name == 'leif' - assert resp.place_of_birth == 'detroit' + resp = await session.g.addV('person').property( + person_class.name, 'leif').property('place_of_birth', 'detroit').one_or_none() + assert isinstance(resp, person_class) + assert resp.name == 'leif' + assert resp.place_of_birth == 'detroit' await app.close() @pytest.mark.asyncio async def test_edge_desialization(self, app, knows_class): session = await app.session() - async with session: - p1 = await session.g.addV('person').one_or_none() - p2 = await session.g.addV('person').one_or_none() - e1 = await session.g.V(p1.id).addE('knows').to( - session.g.V(p2.id)).property( - knows_class.notes, 'somehow').property( - 'how_long', 1).one_or_none() - assert isinstance(e1, knows_class) - assert e1.notes == 'somehow' - assert e1.how_long == 1 + p1 = await session.g.addV('person').one_or_none() + p2 = await session.g.addV('person').one_or_none() + e1 = await session.g.V(p1.id).addE('knows').to( + session.g.V(p2.id)).property( + knows_class.notes, 'somehow').property( + 'how_long', 1).one_or_none() + assert isinstance(e1, knows_class) + assert e1.notes == 'somehow' + assert e1.how_long == 1 await app.close() @pytest.mark.asyncio async def test_unregistered_vertex_deserialization(self, app): session = await app.session() - async with session: - dave = await session.g.addV( - 'unregistered').property('name', 'dave').one_or_none() - assert isinstance(dave, element.GenericVertex) - assert dave.name == 'dave' - assert dave.__label__ == 'unregistered' + dave = await session.g.addV( + 'unregistered').property('name', 'dave').one_or_none() + assert isinstance(dave, element.GenericVertex) + assert dave.name == 'dave' + assert dave.__label__ == 'unregistered' await app.close() @pytest.mark.asyncio async def test_unregistered_edge_desialization(self, app): session = await app.session() - async with session: - p1 = await session.g.addV('person').one_or_none() - p2 = await session.g.addV('person').one_or_none() - e1 = await session.g.V(p1.id).addE('unregistered').to( - session.g.V(p2.id)).property('how_long', 1).one_or_none() - assert isinstance(e1, element.GenericEdge) - assert e1.how_long == 1 - assert e1.__label__ == 'unregistered' + p1 = await session.g.addV('person').one_or_none() + p2 = await session.g.addV('person').one_or_none() + e1 = await session.g.V(p1.id).addE('unregistered').to( + session.g.V(p2.id)).property('how_long', 1).one_or_none() + assert isinstance(e1, element.GenericEdge) + assert e1.how_long == 1 + assert e1.__label__ == 'unregistered' await app.close() @pytest.mark.asyncio async def test_property_deserialization(self, app): session = await app.session() - async with session: - p1 = await session.g.addV('person').property( - 'name', 'leif').one_or_none() - name = await session.g.V(p1.id).properties('name').one_or_none() - assert name['value'] == 'leif' - assert name['label'] == 'name' + p1 = await session.g.addV('person').property( + 'name', 'leif').one_or_none() + name = await session.g.V(p1.id).properties('name').one_or_none() + assert name['value'] == 'leif' + assert name['label'] == 'name' await app.close() @pytest.mark.asyncio async def test_non_element_deserialization(self, app): session = await app.session() - async with session: - p1 = await session.g.addV('person').property( - 'name', 'leif').one_or_none() - one = await session.g.V(p1.id).count().one_or_none() - assert one == 1 + p1 = await session.g.addV('person').property( + 'name', 'leif').one_or_none() + one = await session.g.V(p1.id).count().one_or_none() + assert one == 1 await app.close() diff --git a/tests/test_vertex_properties_functional.py b/tests/test_vertex_properties_functional.py index cda72818e3cc631556d303fc9d6006c10ca65a43..703d085fe769ea3f81ab03f8bd9a2133f8f5c0e9 100644 --- a/tests/test_vertex_properties_functional.py +++ b/tests/test_vertex_properties_functional.py @@ -4,124 +4,119 @@ import pytest @pytest.mark.asyncio async def test_add_update_property(app, person): session = await app.session() - async with session: - person.birthplace = 'Iowa City' - result = await session.save(person) - assert result.birthplace.value == 'Iowa City' - person.birthplace = 'unknown' - result = await session.save(person) - assert result.birthplace.value == 'unknown' - person.birthplace = None - result = await session.save(person) - assert not result.birthplace + person.birthplace = 'Iowa City' + result = await session.save(person) + assert result.birthplace.value == 'Iowa City' + person.birthplace = 'unknown' + result = await session.save(person) + assert result.birthplace.value == 'unknown' + person.birthplace = None + result = await session.save(person) + assert not result.birthplace await app.close() @pytest.mark.asyncio async def test_add_update_list_card_property(app, person): session = await app.session() - async with session: - person.nicknames = ['db', 'dirtydb'] - result = await session.save(person) - assert [v.value for v in result.nicknames] == ['db', 'dirtydb'] - person.nicknames.append('davebshow') - result = await session.save(person) - assert [v.value for v in result.nicknames] == [ - 'db', 'dirtydb', 'davebshow'] - person.nicknames = [] - result = await session.save(person) - assert not result.nicknames - person.nicknames = ['none'] - result = await session.save(person) - assert result.nicknames('none').value == 'none' - person.nicknames = None - result = await session.save(person) - assert not result.nicknames + person.nicknames = ['db', 'dirtydb'] + result = await session.save(person) + assert [v.value for v in result.nicknames] == ['db', 'dirtydb'] + person.nicknames.append('davebshow') + result = await session.save(person) + assert [v.value for v in result.nicknames] == [ + 'db', 'dirtydb', 'davebshow'] + person.nicknames = [] + result = await session.save(person) + assert not result.nicknames + person.nicknames = ['none'] + result = await session.save(person) + assert result.nicknames('none').value == 'none' + person.nicknames = None + result = await session.save(person) + assert not result.nicknames await app.close() @pytest.mark.asyncio async def test_add_update_set_card_property(app, place): session = await app.session() - async with session: - place.important_numbers = set([1, 2]) - result = await session.save(place) - assert {v.value for v in result.important_numbers} == {1, 2} - place.important_numbers = set([3, 4]) - result = await session.save(place) - assert {v.value for v in result.important_numbers} == {3, 4} - place.important_numbers.add(5) - result = await session.save(place) - assert {v.value for v in result.important_numbers} == {3, 4, 5} - place.important_numbers = set() - result = await session.save(place) - assert not result.important_numbers - place.important_numbers = set([1, 2]) - result = await session.save(place) - assert place.important_numbers(1).value == 1 - place.important_numbers = None - result = await session.save(place) - assert not result.important_numbers + place.important_numbers = set([1, 2]) + result = await session.save(place) + assert {v.value for v in result.important_numbers} == {1, 2} + place.important_numbers = set([3, 4]) + result = await session.save(place) + assert {v.value for v in result.important_numbers} == {3, 4} + place.important_numbers.add(5) + result = await session.save(place) + assert {v.value for v in result.important_numbers} == {3, 4, 5} + place.important_numbers = set() + result = await session.save(place) + assert not result.important_numbers + place.important_numbers = set([1, 2]) + result = await session.save(place) + assert place.important_numbers(1).value == 1 + place.important_numbers = None + result = await session.save(place) + assert not result.important_numbers await app.close() @pytest.mark.asyncio async def test_add_update_metas(app, place): session = await app.session() - async with session: - place.historical_name = ['Detroit'] - place.historical_name('Detroit').notes = 'rock city' - place.historical_name('Detroit').year = 1900 - result = await session.save(place) - assert result.historical_name('Detroit').notes == 'rock city' - assert result.historical_name('Detroit').year == 1900 + place.historical_name = ['Detroit'] + place.historical_name('Detroit').notes = 'rock city' + place.historical_name('Detroit').year = 1900 + result = await session.save(place) + assert result.historical_name('Detroit').notes == 'rock city' + assert result.historical_name('Detroit').year == 1900 - place.historical_name('Detroit').notes = 'comeback city' - place.historical_name('Detroit').year = 2016 - result = await session.save(place) - assert result.historical_name('Detroit').notes == 'comeback city' - assert result.historical_name('Detroit').year == 2016 + place.historical_name('Detroit').notes = 'comeback city' + place.historical_name('Detroit').year = 2016 + result = await session.save(place) + assert result.historical_name('Detroit').notes == 'comeback city' + assert result.historical_name('Detroit').year == 2016 - place.historical_name('Detroit').notes = None - place.historical_name('Detroit').year = None - result = await session.save(place) - assert not result.historical_name('Detroit').notes - assert not result.historical_name('Detroit').year + place.historical_name('Detroit').notes = None + place.historical_name('Detroit').year = None + result = await session.save(place) + assert not result.historical_name('Detroit').notes + assert not result.historical_name('Detroit').year await app.close() @pytest.mark.asyncio async def test_add_update_metas_list_card(app, place): session = await app.session() - async with session: - place.historical_name = ['Hispania', 'Al-Andalus'] - place.historical_name('Hispania').notes = 'romans' - place.historical_name('Hispania').year = 200 - place.historical_name('Al-Andalus').notes = 'muslims' - place.historical_name('Al-Andalus').year = 700 - result = await session.save(place) - assert result.historical_name('Hispania').notes == 'romans' - assert result.historical_name('Hispania').year == 200 - assert result.historical_name('Al-Andalus').notes == 'muslims' - assert result.historical_name('Al-Andalus').year == 700 + place.historical_name = ['Hispania', 'Al-Andalus'] + place.historical_name('Hispania').notes = 'romans' + place.historical_name('Hispania').year = 200 + place.historical_name('Al-Andalus').notes = 'muslims' + place.historical_name('Al-Andalus').year = 700 + result = await session.save(place) + assert result.historical_name('Hispania').notes == 'romans' + assert result.historical_name('Hispania').year == 200 + assert result.historical_name('Al-Andalus').notes == 'muslims' + assert result.historical_name('Al-Andalus').year == 700 - place.historical_name('Hispania').notes = 'really old' - place.historical_name('Hispania').year = 200 - place.historical_name('Al-Andalus').notes = 'less old' - place.historical_name('Al-Andalus').year = 700 - result = await session.save(place) - assert result.historical_name('Hispania').notes == 'really old' - assert result.historical_name('Hispania').year == 200 - assert result.historical_name('Al-Andalus').notes == 'less old' - assert result.historical_name('Al-Andalus').year == 700 + place.historical_name('Hispania').notes = 'really old' + place.historical_name('Hispania').year = 200 + place.historical_name('Al-Andalus').notes = 'less old' + place.historical_name('Al-Andalus').year = 700 + result = await session.save(place) + assert result.historical_name('Hispania').notes == 'really old' + assert result.historical_name('Hispania').year == 200 + assert result.historical_name('Al-Andalus').notes == 'less old' + assert result.historical_name('Al-Andalus').year == 700 - place.historical_name('Hispania').notes = None - place.historical_name('Hispania').year = None - place.historical_name('Al-Andalus').notes = None - place.historical_name('Al-Andalus').year = None - result = await session.save(place) - assert not result.historical_name('Hispania').notes - assert not result.historical_name('Hispania').year - assert not result.historical_name('Al-Andalus').notes - assert not result.historical_name('Al-Andalus').year + place.historical_name('Hispania').notes = None + place.historical_name('Hispania').year = None + place.historical_name('Al-Andalus').notes = None + place.historical_name('Al-Andalus').year = None + result = await session.save(place) + assert not result.historical_name('Hispania').notes + assert not result.historical_name('Hispania').year + assert not result.historical_name('Al-Andalus').notes + assert not result.historical_name('Al-Andalus').year await app.close()