|
173 | 173 | },
|
174 | 174 | ]
|
175 | 175 |
|
| 176 | +valid_accelerator_records_fields = [ |
| 177 | + dict( |
| 178 | + measurement_month=6, |
| 179 | + measurement_year=2022, |
| 180 | + uuid="99cf5d02-a573-46a1-b90d-0f7327126876", |
| 181 | + fqan="VO 1 FQAN", |
| 182 | + compute_service="Fake Cloud Service", |
| 183 | + site_name="TEST-Site", |
| 184 | + count=3, |
| 185 | + available_duration=5000, |
| 186 | + accelerator_type="GPU", |
| 187 | + |
| 188 | + model="Foobar A200", |
| 189 | + ), |
| 190 | + dict( |
| 191 | + measurement_month=2, |
| 192 | + measurement_year=2022, |
| 193 | + uuid="99cf5d02-a573-46a1-b90d-0f7327126876", |
| 194 | + fqan="VO 1 FQAN", |
| 195 | + compute_service="Fake Cloud Service", |
| 196 | + site_name="TEST-Site", |
| 197 | + count=30, |
| 198 | + available_duration=5000, |
| 199 | + accelerator_type="GPU", |
| 200 | + |
| 201 | + model="Foobar A300", |
| 202 | + ), |
| 203 | +] |
| 204 | + |
| 205 | +valid_accelerator_records_dict = [ |
| 206 | + { |
| 207 | + "AccUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", |
| 208 | + "AssociatedRecordType": "cloud", |
| 209 | + "AvailableDuration": 5000, |
| 210 | + "Count": 3, |
| 211 | + "FQAN": "VO 1 FQAN", |
| 212 | + "GlobalUserName": "[email protected]", |
| 213 | + "MeasurementMonth": 6, |
| 214 | + "MeasurementYear": 2022, |
| 215 | + "Model": "Foobar A200", |
| 216 | + "SiteName": "TEST-Site", |
| 217 | + "Type": "GPU", |
| 218 | + "CloudType": cloud_type, |
| 219 | + "CloudComputeService": "Fake Cloud Service", |
| 220 | + }, |
| 221 | + { |
| 222 | + "AccUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", |
| 223 | + "AssociatedRecordType": "cloud", |
| 224 | + "AvailableDuration": 5000, |
| 225 | + "Count": 30, |
| 226 | + "FQAN": "VO 1 FQAN", |
| 227 | + "GlobalUserName": "[email protected]", |
| 228 | + "MeasurementMonth": 2, |
| 229 | + "MeasurementYear": 2022, |
| 230 | + "Model": "Foobar A300", |
| 231 | + "SiteName": "TEST-Site", |
| 232 | + "Type": "GPU", |
| 233 | + "CloudType": cloud_type, |
| 234 | + "CloudComputeService": "Fake Cloud Service", |
| 235 | + }, |
| 236 | +] |
| 237 | + |
176 | 238 | # Cloud Record fixtures
|
177 | 239 |
|
178 | 240 |
|
@@ -260,6 +322,41 @@ def ip_record_list(ip_record, another_ip_record):
|
260 | 322 | return [ip_record, another_ip_record]
|
261 | 323 |
|
262 | 324 |
|
| 325 | +# Accelerator records |
| 326 | + |
| 327 | + |
| 328 | +@pytest.fixture(scope="module") |
| 329 | +def accelerator_record(): |
| 330 | + """Get a fixture for the AcceleratorRecord.""" |
| 331 | + record = caso.record.AcceleratorRecord(**valid_accelerator_records_fields[0]) |
| 332 | + return record |
| 333 | + |
| 334 | + |
| 335 | +@pytest.fixture(scope="module") |
| 336 | +def another_accelerator_record(): |
| 337 | + """Get another fixture for the AcceleratorRecord.""" |
| 338 | + record = caso.record.AcceleratorRecord(**valid_accelerator_records_fields[1]) |
| 339 | + return record |
| 340 | + |
| 341 | + |
| 342 | +@pytest.fixture(scope="module") |
| 343 | +def valid_accelerator_record(): |
| 344 | + """Get a fixture for a valid record.""" |
| 345 | + return valid_accelerator_records_dict[0] |
| 346 | + |
| 347 | + |
| 348 | +@pytest.fixture(scope="module") |
| 349 | +def valid_accelerator_records(): |
| 350 | + """Get a fixture for valid records as a dict.""" |
| 351 | + return valid_accelerator_records_dict |
| 352 | + |
| 353 | + |
| 354 | +@pytest.fixture(scope="module") |
| 355 | +def accelerator_record_list(accelerator_record, another_accelerator_record): |
| 356 | + """Get a fixture for a list of Accelerator records.""" |
| 357 | + return [accelerator_record, another_accelerator_record] |
| 358 | + |
| 359 | + |
263 | 360 | # SSM entries
|
264 | 361 |
|
265 | 362 |
|
@@ -398,3 +495,74 @@ def expected_message_ip():
|
398 | 495 | "]}"
|
399 | 496 | )
|
400 | 497 | return message
|
| 498 | + |
| 499 | + |
| 500 | +@pytest.fixture |
| 501 | +def expected_entries_accelerator(): |
| 502 | + """Get a fixture for all accelerator entries.""" |
| 503 | + ssm_entries = [ |
| 504 | + '{"SiteName": "TEST-Site", ' |
| 505 | + f'"CloudType": "{cloud_type}", ' |
| 506 | + '"CloudComputeService": "Fake Cloud Service", ' |
| 507 | + '"AccUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", ' |
| 508 | + '"GlobalUserName": "[email protected]", ' |
| 509 | + '"FQAN": "VO 1 FQAN", ' |
| 510 | + '"Count": 3, ' |
| 511 | + '"AvailableDuration": 5000, ' |
| 512 | + '"MeasurementMonth": 6, ' |
| 513 | + '"MeasurementYear": 2022, ' |
| 514 | + '"AssociatedRecordType": "cloud", ' |
| 515 | + '"Type": "GPU", ' |
| 516 | + '"Model": "Foobar A200"}', |
| 517 | + '{"SiteName": "TEST-Site", ' |
| 518 | + f'"CloudType": "{cloud_type}", ' |
| 519 | + '"CloudComputeService": "Fake Cloud Service", ' |
| 520 | + '"AccUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", ' |
| 521 | + '"GlobalUserName": "[email protected]", ' |
| 522 | + '"FQAN": "VO 1 FQAN", ' |
| 523 | + '"Count": 30, ' |
| 524 | + '"AvailableDuration": 5000, ' |
| 525 | + '"MeasurementMonth": 2, ' |
| 526 | + '"MeasurementYear": 2022, ' |
| 527 | + '"AssociatedRecordType": "cloud", ' |
| 528 | + '"Type": "GPU", ' |
| 529 | + '"Model": "Foobar A300"}', |
| 530 | + ] |
| 531 | + |
| 532 | + return ssm_entries |
| 533 | + |
| 534 | + |
| 535 | +@pytest.fixture |
| 536 | +def expected_message_accelerator(): |
| 537 | + """Get a fixture for a complete Accelerator message.""" |
| 538 | + message = ( |
| 539 | + '{"Type": "APEL-accelerator-message", "Version": "0.1", "UsageRecords": [' |
| 540 | + '{"SiteName": "TEST-Site", ' |
| 541 | + f'"CloudType": "{cloud_type}", ' |
| 542 | + '"CloudComputeService": "Fake Cloud Service", ' |
| 543 | + '"AccUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", ' |
| 544 | + '"GlobalUserName": "[email protected]", ' |
| 545 | + '"FQAN": "VO 1 FQAN", ' |
| 546 | + '"Count": 3, ' |
| 547 | + '"AvailableDuration": 5000, ' |
| 548 | + '"MeasurementMonth": 6, ' |
| 549 | + '"MeasurementYear": 2022, ' |
| 550 | + '"AssociatedRecordType": "cloud", ' |
| 551 | + '"Type": "GPU", ' |
| 552 | + '"Model": "Foobar A200"}, ' |
| 553 | + '{"SiteName": "TEST-Site", ' |
| 554 | + f'"CloudType": "{cloud_type}", ' |
| 555 | + '"CloudComputeService": "Fake Cloud Service", ' |
| 556 | + '"AccUUID": "99cf5d02-a573-46a1-b90d-0f7327126876", ' |
| 557 | + '"GlobalUserName": "[email protected]", ' |
| 558 | + '"FQAN": "VO 1 FQAN", ' |
| 559 | + '"Count": 30, ' |
| 560 | + '"AvailableDuration": 5000, ' |
| 561 | + '"MeasurementMonth": 2, ' |
| 562 | + '"MeasurementYear": 2022, ' |
| 563 | + '"AssociatedRecordType": "cloud", ' |
| 564 | + '"Type": "GPU", ' |
| 565 | + '"Model": "Foobar A300"}' |
| 566 | + "]}" |
| 567 | + ) |
| 568 | + return message |
0 commit comments