|
236 | 236 | },
|
237 | 237 | ]
|
238 | 238 |
|
| 239 | +valid_storage_records_fields = [ |
| 240 | + dict( |
| 241 | + uuid="99cf5d02-a573-46a1-b90d-0f7327126876", |
| 242 | + site_name="TEST-Site", |
| 243 | + name="Test Volume 1", |
| 244 | + user_id="63296dcd-b652-4039-b274-aaa70f9d57e5", |
| 245 | + group_id="313c6f62-e05f-4ec7-b0f2-256612db18f5", |
| 246 | + fqan="VO 1 FQAN", |
| 247 | + compute_service="Fake Cloud Service", |
| 248 | + status="in-use", |
| 249 | + active_duration=400, |
| 250 | + measure_time=now, |
| 251 | + start_time=now - datetime.timedelta(days=5), |
| 252 | + capacity=322122547200, |
| 253 | + |
| 254 | + ), |
| 255 | + dict( |
| 256 | + uuid="99cf5d02-a573-46a1-b90d-0f7327126876", |
| 257 | + site_name="TEST-Site", |
| 258 | + name="Test Volume 1", |
| 259 | + user_id="63296dcd-b652-4039-b274-aaa70f9d57e5", |
| 260 | + group_id="313c6f62-e05f-4ec7-b0f2-256612db18f5", |
| 261 | + fqan="VO 2 FQAN", |
| 262 | + compute_service="Fake Cloud Service", |
| 263 | + status="in-use", |
| 264 | + active_duration=400, |
| 265 | + measure_time=now, |
| 266 | + start_time=now - datetime.timedelta(days=6), |
| 267 | + capacity=122122547200, |
| 268 | + |
| 269 | + ), |
| 270 | +] |
| 271 | + |
| 272 | +valid_storage_records_dict = [ |
| 273 | + { |
| 274 | + "SiteName": "TEST-Site", |
| 275 | + "CloudType": cloud_type, |
| 276 | + "CloudComputeService": "Fake Cloud Service", |
| 277 | + "VolumeUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", |
| 278 | + "RecordName": "Test Volume 1", |
| 279 | + "LocalUser": "63296dcd-b652-4039-b274-aaa70f9d57e5", |
| 280 | + "GlobalUserName": "[email protected]", |
| 281 | + "LocalGroup": "313c6f62-e05f-4ec7-b0f2-256612db18f5", |
| 282 | + "FQAN": "VO 1 FQAN", |
| 283 | + "ActiveDuration": 400, |
| 284 | + "CreateTime": "2023-05-25T21:59:06+00:00", |
| 285 | + "StartTime": "2023-05-20T21:59:06+00:00", |
| 286 | + "Type": "Block Storage (cinder)", |
| 287 | + "Status": "in-use", |
| 288 | + "Capacity": 322122547200, |
| 289 | + }, |
| 290 | + { |
| 291 | + "SiteName": "TEST-Site", |
| 292 | + "CloudType": cloud_type, |
| 293 | + "CloudComputeService": "Fake Cloud Service", |
| 294 | + "VolumeUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", |
| 295 | + "RecordName": "Test Volume 2", |
| 296 | + "LocalUser": "63296dcd-b652-4039-b274-aaa70f9d57e5", |
| 297 | + "GlobalUserName": "[email protected]", |
| 298 | + "LocalGroup": "313c6f62-e05f-4ec7-b0f2-256612db18f5", |
| 299 | + "FQAN": "VO 2 FQAN", |
| 300 | + "ActiveDuration": 400, |
| 301 | + "CreateTime": "2023-05-25T21:59:06+00:00", |
| 302 | + "StartTime": "2023-05-20T21:59:06+00:00", |
| 303 | + "Type": "Block Storage (cinder)", |
| 304 | + "Status": "in-use", |
| 305 | + "Capacity": 122122547200, |
| 306 | + }, |
| 307 | +] |
| 308 | + |
239 | 309 | # Cloud Record fixtures
|
240 | 310 |
|
241 | 311 |
|
@@ -362,6 +432,43 @@ def accelerator_record_list(
|
362 | 432 | return [accelerator_record, another_accelerator_record]
|
363 | 433 |
|
364 | 434 |
|
| 435 | +# Storage records |
| 436 | + |
| 437 | + |
| 438 | +@pytest.fixture(scope="module") |
| 439 | +def storage_record() -> caso.record.StorageRecord: |
| 440 | + """Get a fixture for the StorageRecord.""" |
| 441 | + record = caso.record.StorageRecord(**valid_storage_records_fields[0]) |
| 442 | + return record |
| 443 | + |
| 444 | + |
| 445 | +@pytest.fixture(scope="module") |
| 446 | +def another_storage_record() -> caso.record.StorageRecord: |
| 447 | + """Get another fixture for the StorageRecord.""" |
| 448 | + record = caso.record.StorageRecord(**valid_storage_records_fields[1]) |
| 449 | + return record |
| 450 | + |
| 451 | + |
| 452 | +@pytest.fixture(scope="module") |
| 453 | +def valid_storage_record() -> dict: |
| 454 | + """Get a fixture for a valid record.""" |
| 455 | + return valid_storage_records_dict[0] |
| 456 | + |
| 457 | + |
| 458 | +@pytest.fixture(scope="module") |
| 459 | +def valid_storage_records() -> typing.List[dict]: |
| 460 | + """Get a fixture for valid records as a dict.""" |
| 461 | + return valid_storage_records_dict |
| 462 | + |
| 463 | + |
| 464 | +@pytest.fixture(scope="module") |
| 465 | +def storage_record_list( |
| 466 | + storage_record, another_storage_record |
| 467 | +) -> typing.List[caso.record.StorageRecord]: |
| 468 | + """Get a fixture for a list of Storage records.""" |
| 469 | + return [storage_record, another_storage_record] |
| 470 | + |
| 471 | + |
365 | 472 | # SSM entries
|
366 | 473 |
|
367 | 474 |
|
@@ -571,3 +678,48 @@ def expected_message_accelerator() -> str:
|
571 | 678 | "]}"
|
572 | 679 | )
|
573 | 680 | return message
|
| 681 | + |
| 682 | + |
| 683 | +@pytest.fixture |
| 684 | +def expected_entries_storage(storage_record_list) -> list[caso.record.StorageRecord]: |
| 685 | + """Get a fixture for all Storage entries.""" |
| 686 | + ssm_entries = storage_record_list.copy() |
| 687 | + return ssm_entries |
| 688 | + |
| 689 | + |
| 690 | +@pytest.fixture |
| 691 | +def expected_message_storage() -> str: |
| 692 | + """Get a fixture for a complete Storage message.""" |
| 693 | + message = ( |
| 694 | + '<sr:StorageUsageRecords xmlns:sr="http://eu-emi.eu/namespaces/2011/02/storagerecord">' # noqa |
| 695 | + "<sr:StorageUsageRecord>" |
| 696 | + '<sr:RecordIdentity sr:createTime="2023-05-25T21:59:06+00:00" sr:recordId="99cf5d02-a573-46a1-b90d-0f7327126876" />' # noqa |
| 697 | + "<sr:StorageSystem>Fake Cloud Service</sr:StorageSystem>" |
| 698 | + "<sr:Site>TEST-Site</sr:Site>" |
| 699 | + "<sr:SubjectIdentity>" |
| 700 | + "<sr:LocalUser>63296dcd-b652-4039-b274-aaa70f9d57e5</sr:LocalUser>" |
| 701 | + "<sr:LocalGroup>313c6f62-e05f-4ec7-b0f2-256612db18f5</sr:LocalGroup>" |
| 702 | + "<sr:UserIdentity>[email protected]</sr:UserIdentity>" |
| 703 | + "<sr:Group>VO 1 FQAN</sr:Group>" |
| 704 | + "</sr:SubjectIdentity>" |
| 705 | + "<sr:StartTime>2023-05-20T21:59:06+00:00</sr:StartTime>" |
| 706 | + "<sr:EndTime>2023-05-25T21:59:06+00:00</sr:EndTime>" |
| 707 | + "<sr:ResourceCapacityUsed>345876451382054092800</sr:ResourceCapacityUsed>" |
| 708 | + "</sr:StorageUsageRecord>" |
| 709 | + "<sr:StorageUsageRecord>" |
| 710 | + '<sr:RecordIdentity sr:createTime="2023-05-25T21:59:06+00:00" sr:recordId="99cf5d02-a573-46a1-b90d-0f7327126876" />' # noqa |
| 711 | + "<sr:StorageSystem>Fake Cloud Service</sr:StorageSystem>" |
| 712 | + "<sr:Site>TEST-Site</sr:Site>" |
| 713 | + "<sr:SubjectIdentity>" |
| 714 | + "<sr:LocalUser>63296dcd-b652-4039-b274-aaa70f9d57e5</sr:LocalUser>" |
| 715 | + "<sr:LocalGroup>313c6f62-e05f-4ec7-b0f2-256612db18f5</sr:LocalGroup>" |
| 716 | + "<sr:UserIdentity>[email protected]</sr:UserIdentity>" |
| 717 | + "<sr:Group>VO 2 FQAN</sr:Group>" |
| 718 | + "</sr:SubjectIdentity>" |
| 719 | + "<sr:StartTime>2023-05-19T21:59:06+00:00</sr:StartTime>" |
| 720 | + "<sr:EndTime>2023-05-25T21:59:06+00:00</sr:EndTime>" |
| 721 | + "<sr:ResourceCapacityUsed>131128086582054092800</sr:ResourceCapacityUsed>" |
| 722 | + "</sr:StorageUsageRecord>" |
| 723 | + "</sr:StorageUsageRecords>" |
| 724 | + ) |
| 725 | + return message.encode("utf-8") |
0 commit comments