Skip to content

Commit

Permalink
Mock request object
Browse files Browse the repository at this point in the history
Making reference to the `batman.id` value for the primary key in the
request object was causing PostgreSQL tests to hang. This commit matches
the way that the request object is being mocked in the
`test_models_actions` file. Local tests with a PostgreSQL instance built
in Docker are now working.
  • Loading branch information
lukeclimen committed Apr 15, 2024
1 parent 11122b7 commit fde2026
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def list_query(self, request: Request) -> Select:

async def test_edit_form_query() -> None:
session = session_maker()
batman = User(name="batman")
batman = User(id=123, name="batman")
batcave = Address(user=batman, name="bat cave")
wayne_manor = Address(user=batman, name="wayne manor")
session.add(batman)
Expand All @@ -405,8 +405,13 @@ def edit_form_query(self, request: Request) -> Select:
)

view = UserAdmin()
request = Request({"type": "http", "path_params": {"pk": batman.id}})
user_obj = await view.get_object_for_edit(request)

class RequestObject(object):
pass

request_object = RequestObject()
request_object.path_params = {"pk": 123}
user_obj = await view.get_object_for_edit(request_object)

assert len(user_obj.addresses) == 1

Expand Down

0 comments on commit fde2026

Please sign in to comment.