Skip to content

Commit 6b3be0b

Browse files
committed
Params formatting in tests
1 parent 8f68078 commit 6b3be0b

48 files changed

Lines changed: 334 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/benchmarks/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ def configuration_filename_sqlite_fixture() -> str:
1414
"""Retrieve configuration file name to be used by benchmarks.
1515
1616
Parameters:
17+
----------
1718
None
1819
1920
Returns:
21+
-------
2022
str: Path to the benchmark configuration file to load.
2123
"""
2224
return "tests/configuration/benchmarks-sqlite.yaml"
@@ -27,9 +29,11 @@ def configuration_filename_postgres_fixture() -> str:
2729
"""Retrieve configuration file name to be used by benchmarks.
2830
2931
Parameters:
32+
----------
3033
None
3134
3235
Returns:
36+
-------
3337
str: Path to the benchmark configuration file to load.
3438
"""
3539
return "tests/configuration/benchmarks-postgres.yaml"
@@ -46,10 +50,12 @@ def sqlite_database_fixture(configuration_filename_sqlite: str, tmp_path: Path)
4650
- Initializes the DB engine and creates required tables.
4751
4852
Parameters:
53+
----------
4954
configuration_filename_sqlite (str): Path to the YAML configuration file to load.
5055
tmp_path (Path): pytest-provided temporary directory for creating the DB file.
5156
5257
Raises:
58+
------
5359
AssertionError: If the configuration does not include an sqlite configuration.
5460
"""
5561
# try to load the configuration containing SQLite database setup
@@ -102,9 +108,11 @@ def postgres_database_fixture(configuration_filename_postgres: str) -> None:
102108
- Initializes the DB engine and creates required tables.
103109
104110
Parameters:
111+
----------
105112
configuration_filename_postgres (str): Path to the YAML configuration file to load.
106113
107114
Raises:
115+
------
108116
AssertionError: If the configuration does not include an postgres configuration.
109117
"""
110118
# try to load the configuration containing postgres database setup

tests/benchmarks/data_generators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def generate_model_for_provider(provider: str) -> str:
2828
"""Return a randomly chosen model ID for a given provider.
2929
3030
Parameters:
31+
----------
3132
provider (str): Name of the provider for which to pick a model.
3233
3334
Returns:
35+
-------
3436
str: A model identifier associated with the given provider. If the
3537
provider is unknown, a fallback value of "foo" is returned.
3638
"""

tests/benchmarks/db_benchmarks.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ def store_new_user_conversation(
2727
session.
2828
2929
Parameters:
30+
----------
3031
session (Session): SQLAlchemy session used to persist the record.
3132
id (Optional[str]): Optional explicit ID to assign to the new conversation.
3233
If not provided, a generated suid will be used.
3334
user_id (Optional[str]): Optional explicit user ID to assign to the new
3435
conversation. If not provided, a generated suid will be used.
3536
3637
Returns:
38+
-------
3739
None
3840
"""
3941
provider = generate_provider()
@@ -60,10 +62,12 @@ def update_user_conversation(session: Session, id: str) -> None:
6062
session.
6163
6264
Parameters:
65+
----------
6366
session (Session): SQLAlchemy session used to persist the record.
6467
id (str): Explicit ID to assign to the new conversation.
6568
6669
Returns:
70+
-------
6771
None
6872
"""
6973
provider = generate_provider()
@@ -89,9 +93,11 @@ def list_conversation_for_all_users(session: Session) -> None:
8993
that measures the listing performance.
9094
9195
Parameters:
96+
----------
9297
session (Session): SQLAlchemy session used to query conversations.
9398
9499
Returns:
100+
-------
95101
None
96102
"""
97103
query = session.query(UserConversation)
@@ -110,9 +116,11 @@ def retrieve_conversation(
110116
is intended for use in a benchmark that measures the listing performance.
111117
112118
Parameters:
119+
----------
113120
session (Session): SQLAlchemy session used to query conversations.
114121
115122
Returns:
123+
-------
116124
None
117125
"""
118126
query = session.query(UserConversation).filter_by(id=conversation_id)
@@ -133,9 +141,11 @@ def retrieve_conversation_for_one_user(
133141
is intended for use in a benchmark that measures the listing performance.
134142
135143
Parameters:
144+
----------
136145
session (Session): SQLAlchemy session used to query conversations.
137146
138147
Returns:
148+
-------
139149
None
140150
"""
141151
query = session.query(UserConversation).filter_by(
@@ -157,9 +167,11 @@ def list_conversation_for_one_user(session: Session, user_id: str) -> None:
157167
that measures the listing performance.
158168
159169
Parameters:
170+
----------
160171
session (Session): SQLAlchemy session used to query conversations.
161172
162173
Returns:
174+
-------
163175
None
164176
"""
165177
query = session.query(UserConversation).filter_by(user_id=user_id)
@@ -178,10 +190,12 @@ def benchmark_store_new_user_conversations(
178190
benchmark task stores one more conversation (using the helper above).
179191
180192
Parameters:
193+
----------
181194
benchmark (BenchmarkFixture): pytest-benchmark fixture to run the measurement.
182195
records_to_insert (int): Number of records to pre-populate before benchmarking.
183196
184197
Returns:
198+
-------
185199
None
186200
"""
187201
with get_session() as session:
@@ -202,10 +216,12 @@ def benchmark_update_user_conversation(
202216
and then benchmarks updating that conversation.
203217
204218
Parameters:
219+
----------
205220
benchmark (BenchmarkFixture): pytest-benchmark fixture to run the measurement.
206221
records_to_insert (int): Number of records to pre-populate before benchmarking.
207222
208223
Returns:
224+
-------
209225
None
210226
"""
211227
with get_session() as session:
@@ -232,10 +248,12 @@ def benchmark_list_conversations_for_all_users(
232248
the performance of querying and retrieving all UserConversation rows.
233249
234250
Parameters:
251+
----------
235252
benchmark (BenchmarkFixture): pytest-benchmark fixture to run the measurement.
236253
records_to_insert (int): Number of records to pre-populate before benchmarking.
237254
238255
Returns:
256+
-------
239257
None
240258
"""
241259
with get_session() as session:
@@ -255,10 +273,12 @@ def benchmark_list_conversations_for_one_user(
255273
the performance of querying and retrieving all UserConversation rows.
256274
257275
Parameters:
276+
----------
258277
benchmark (BenchmarkFixture): pytest-benchmark fixture to run the measurement.
259278
records_to_insert (int): Number of records to pre-populate before benchmarking.
260279
261280
Returns:
281+
-------
262282
None
263283
"""
264284
with get_session() as session:
@@ -281,10 +301,12 @@ def benchmark_retrieve_conversation(
281301
the performance of querying and retrieving one UserConversation record.
282302
283303
Parameters:
304+
----------
284305
benchmark (BenchmarkFixture): pytest-benchmark fixture to run the measurement.
285306
records_to_insert (int): Number of records to pre-populate before benchmarking.
286307
287308
Returns:
309+
-------
288310
None
289311
"""
290312
with get_session() as session:
@@ -309,10 +331,12 @@ def benchmark_retrieve_conversation_for_one_user(
309331
the performance of querying and retrieving one UserConversation record.
310332
311333
Parameters:
334+
----------
312335
benchmark (BenchmarkFixture): pytest-benchmark fixture to run the measurement.
313336
records_to_insert (int): Number of records to pre-populate before benchmarking.
314337
315338
Returns:
339+
-------
316340
None
317341
"""
318342
with get_session() as session:

0 commit comments

Comments
 (0)