Skip to content

Commit eaf801a

Browse files
committed
Include type annotations on fixtures
1 parent 0be25b5 commit eaf801a

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

caso/tests/conftest.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""Fixtures for cASO tests."""
1818

1919
import datetime
20+
import typing
2021

2122
import pytest
2223

@@ -239,7 +240,7 @@
239240

240241

241242
@pytest.fixture(scope="module")
242-
def cloud_record():
243+
def cloud_record() -> caso.record.CloudRecord:
243244
"""Get a fixture for the CloudRecord."""
244245
record = caso.record.CloudRecord(**valid_cloud_records_fields[0])
245246
# Remove this when moving to Pydantic 2
@@ -249,7 +250,7 @@ def cloud_record():
249250

250251

251252
@pytest.fixture(scope="module")
252-
def another_cloud_record():
253+
def another_cloud_record() -> caso.record.CloudRecord:
253254
"""Get another fixture for the CloudRecord."""
254255
record = caso.record.CloudRecord(**valid_cloud_records_fields[1])
255256
record.wall_duration = 432000
@@ -258,25 +259,27 @@ def another_cloud_record():
258259

259260

260261
@pytest.fixture(scope="module")
261-
def valid_cloud_record():
262+
def valid_cloud_record() -> dict:
262263
"""Get a fixture for a valid record."""
263264
return valid_cloud_records_dict[0]
264265

265266

266267
@pytest.fixture(scope="module")
267-
def valid_cloud_records():
268+
def valid_cloud_records() -> typing.List[dict]:
268269
"""Get a fixture for valid records as a dict."""
269270
return valid_cloud_records_dict
270271

271272

272273
@pytest.fixture(scope="module")
273-
def another_valid_cloud_record():
274+
def another_valid_cloud_record() -> dict:
274275
"""Get another fixture for a valid record as a dict."""
275276
return valid_cloud_records_dict[0]
276277

277278

278279
@pytest.fixture(scope="module")
279-
def cloud_record_list(cloud_record, another_cloud_record):
280+
def cloud_record_list(
281+
cloud_record, another_cloud_record
282+
) -> typing.List[caso.record.CloudRecord]:
280283
"""Get a fixture for a list of valid records."""
281284
return [cloud_record, another_cloud_record]
282285

@@ -285,39 +288,39 @@ def cloud_record_list(cloud_record, another_cloud_record):
285288

286289

287290
@pytest.fixture(scope="module")
288-
def ip_record():
291+
def ip_record() -> caso.record.IPRecord:
289292
"""Get a fixture for an IP record."""
290293
record = caso.record.IPRecord(**valid_ip_records_fields[0])
291294
return record
292295

293296

294297
@pytest.fixture(scope="module")
295-
def another_ip_record():
298+
def another_ip_record() -> caso.record.IPRecord:
296299
"""Get another fixture for an IP record."""
297300
record = caso.record.IPRecord(**valid_ip_records_fields[1])
298301
return record
299302

300303

301304
@pytest.fixture(scope="module")
302-
def valid_ip_record():
305+
def valid_ip_record() -> dict:
303306
"""Get a fixture for a valid IP record as a dict."""
304307
return valid_ip_records_dict[0]
305308

306309

307310
@pytest.fixture(scope="module")
308-
def valid_ip_records():
311+
def valid_ip_records() -> typing.List[dict]:
309312
"""Get a fixture for all IP records as a dict."""
310313
return valid_ip_records_dict
311314

312315

313316
@pytest.fixture(scope="module")
314-
def another_valid_ip_record():
317+
def another_valid_ip_record() -> dict:
315318
"""Get another fixture for an IP record as a dict."""
316-
return valid_ip_records_dict[0]
319+
return valid_ip_records_dict[1]
317320

318321

319322
@pytest.fixture(scope="module")
320-
def ip_record_list(ip_record, another_ip_record):
323+
def ip_record_list(ip_record, another_ip_record) -> typing.List[caso.record.IPRecord]:
321324
"""Get a fixture for a list of IP records."""
322325
return [ip_record, another_ip_record]
323326

@@ -326,33 +329,35 @@ def ip_record_list(ip_record, another_ip_record):
326329

327330

328331
@pytest.fixture(scope="module")
329-
def accelerator_record():
332+
def accelerator_record() -> caso.record.AcceleratorRecord:
330333
"""Get a fixture for the AcceleratorRecord."""
331334
record = caso.record.AcceleratorRecord(**valid_accelerator_records_fields[0])
332335
return record
333336

334337

335338
@pytest.fixture(scope="module")
336-
def another_accelerator_record():
339+
def another_accelerator_record() -> caso.record.AcceleratorRecord:
337340
"""Get another fixture for the AcceleratorRecord."""
338341
record = caso.record.AcceleratorRecord(**valid_accelerator_records_fields[1])
339342
return record
340343

341344

342345
@pytest.fixture(scope="module")
343-
def valid_accelerator_record():
346+
def valid_accelerator_record() -> dict:
344347
"""Get a fixture for a valid record."""
345348
return valid_accelerator_records_dict[0]
346349

347350

348351
@pytest.fixture(scope="module")
349-
def valid_accelerator_records():
352+
def valid_accelerator_records() -> typing.List[dict]:
350353
"""Get a fixture for valid records as a dict."""
351354
return valid_accelerator_records_dict
352355

353356

354357
@pytest.fixture(scope="module")
355-
def accelerator_record_list(accelerator_record, another_accelerator_record):
358+
def accelerator_record_list(
359+
accelerator_record, another_accelerator_record
360+
) -> typing.List[caso.record.AcceleratorRecord]:
356361
"""Get a fixture for a list of Accelerator records."""
357362
return [accelerator_record, another_accelerator_record]
358363

@@ -361,7 +366,7 @@ def accelerator_record_list(accelerator_record, another_accelerator_record):
361366

362367

363368
@pytest.fixture
364-
def expected_entries_cloud():
369+
def expected_entries_cloud() -> typing.List[str]:
365370
"""Get a fixture for all cloud entries."""
366371
ssm_entries = [
367372
"CloudComputeService: Fake Cloud Service\n"
@@ -408,7 +413,7 @@ def expected_entries_cloud():
408413

409414

410415
@pytest.fixture
411-
def expected_message_cloud():
416+
def expected_message_cloud() -> str:
412417
"""Get a fixture for a complete Cloud message."""
413418
message = (
414419
"APEL-cloud-message: v0.4\n"
@@ -436,7 +441,7 @@ def expected_message_cloud():
436441

437442

438443
@pytest.fixture
439-
def expected_entries_ip():
444+
def expected_entries_ip() -> typing.List[str]:
440445
"""Get a fixture for all IP entries."""
441446
ssm_entries = [
442447
'{"SiteName": "TEST-Site", '
@@ -466,7 +471,7 @@ def expected_entries_ip():
466471

467472

468473
@pytest.fixture
469-
def expected_message_ip():
474+
def expected_message_ip() -> str:
470475
"""Get a fixture for a complete IP message."""
471476
message = (
472477
'{"Type": "APEL Public IP message", "Version": "0.2", "UsageRecords": ['
@@ -498,7 +503,7 @@ def expected_message_ip():
498503

499504

500505
@pytest.fixture
501-
def expected_entries_accelerator():
506+
def expected_entries_accelerator() -> typing.List[str]:
502507
"""Get a fixture for all accelerator entries."""
503508
ssm_entries = [
504509
'{"SiteName": "TEST-Site", '
@@ -533,7 +538,7 @@ def expected_entries_accelerator():
533538

534539

535540
@pytest.fixture
536-
def expected_message_accelerator():
541+
def expected_message_accelerator() -> str:
537542
"""Get a fixture for a complete Accelerator message."""
538543
message = (
539544
'{"Type": "APEL-accelerator-message", "Version": "0.1", "UsageRecords": ['

0 commit comments

Comments
 (0)