Coverage for tests/test_batch.py: 100%
10 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
1import inspect
3from prisma import Prisma
6def test_ensure_batch_and_action_signatures_are_equal(client: Prisma) -> None:
7 """Batch method signature is the same as it's corresponding client method
9 This is to ensure that if an client method is updated then it's corresponding
10 batch method must also be updated.
12 I acknowledge that the presence of this test would normally be considered the
13 result of an anti-pattern but I could not figure out any good method for
14 implementing batching and client methods together while maintaining static
15 type safety and without making the templates horrible to maintain. If you
16 have found a method that you think is good please make an issue/PR.
17 """
18 actions = client.user
19 for name, meth in inspect.getmembers(client.batch_().user, inspect.ismethod):
20 if name.startswith('_'):
21 continue
23 actual = inspect.signature(meth).replace(return_annotation=inspect.Signature.empty)
24 expected = inspect.signature(getattr(actions, name)).replace(return_annotation=inspect.Signature.empty)
25 assert actual == expected, f'{name} methods are inconsistent'