Skip to content

Commit

Permalink
simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Jan 21, 2025
1 parent 94f24ec commit 3030691
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
21 changes: 12 additions & 9 deletions tests/reflection/test_table_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ async def test_can_reflect_existing_table():
assert len(users) == 1


async def test_can_defer_loading():
await HubUser.query.create(name="Test", title="a title", description="desc")

user = await ReflectedUser.query.defer("description").get()

assert "description" not in user.__dict__
assert user.description == "desc"
assert "description" in user.__dict__


async def test_can_reflect_existing_table_with_not_all_fields():
await HubUser.query.create(name="Test", title="a title", description="desc")

Expand All @@ -114,6 +124,7 @@ async def test_can_reflect_existing_table_with_not_all_fields_and_create_record(

assert len(users) == 1

# description is not a field and won't be serialized
await NewReflectedUser.query.create(name="Test2", title="A new title", description="lol")

users = await HubUser.query.all()
Expand All @@ -123,17 +134,9 @@ async def test_can_reflect_existing_table_with_not_all_fields_and_create_record(
user = users[1]

assert user.name == "Test2"
# not a reflected field so kept unset
assert user.description is None

users = await NewReflectedUser.query.defer("description").all()

assert len(users) == 2

user = users[1]

assert user.name == "Test2"
assert "description" not in user.__dict__


async def test_can_reflect_and_edit_existing_table():
await HubUser.query.create(name="Test", title="a title", description="desc")
Expand Down
9 changes: 0 additions & 9 deletions tests/reflection/test_table_reflection_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,6 @@ async def test_can_reflect_existing_table_with_not_all_fields_and_create_record(
assert user.name == "Test2"
assert user.description is None

users = await NewReflectedUser.query.defer("description").all()

assert len(users) == 2

user = users[1]

assert user.name == "Test2"
assert "description" not in user.__dict__


async def test_can_reflect_and_edit_existing_table():
await HubUser.query.create(name="Test", title="a title", description="desc")
Expand Down

0 comments on commit 3030691

Please sign in to comment.