Skip to content

Commit

Permalink
Merge branch 'feature/PI-158-create_product_id' into release/2024-01-05
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslinnell committed Jan 5, 2024
2 parents 95b3637 + cdefdd1 commit 2e62de9
Show file tree
Hide file tree
Showing 37 changed files with 380 additions and 290 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
- "--exclude=.git,__pycache__,dist,.venv,tests"

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.12.1
hooks:
- id: black
language_version: python3
Expand Down
25 changes: 3 additions & 22 deletions feature_tests/domain/features/device.failure.feature
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
Feature: Device Failure Scenarios

Scenario: Device ID is not valid
Given Product Teams
| id | name | ods_code |
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | not_a_valid_id |
| name | My Device |
| type | product |
Then the operation is not successful
And the error is ValidationError on fields
| Device.id |

Scenario: Device name is not valid
Given Product Teams
| id | name | ods_code |
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | XXX-YYY |
| name | My Device 🚀 |
| type | product |
Then the operation is not successful
Expand All @@ -32,7 +18,6 @@ Feature: Device Failure Scenarios
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | XXX-YYY |
| name | My Device |
| type | not_a_type |
Then the operation is not successful
Expand All @@ -45,20 +30,18 @@ Feature: Device Failure Scenarios
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | not_an_id |
| name | My Device 🚀 |
| type | not_a_type |
Then the operation is not successful
And the error is ValidationError on fields
| Device.id | Device.name | Device.type |
| Device.name | Device.type |

Scenario: Invalid product key types
Given Product Teams
| id | name | ods_code |
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | XXX-YYY |
| name | My Product |
| type | product |
| keys.0.key | AAA-CCC-DDD |
Expand All @@ -73,7 +56,6 @@ Feature: Device Failure Scenarios
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | XXX-YYY |
| name | My Product |
| type | product |
| keys.0.key | not_a_valid_product_id |
Expand All @@ -88,12 +70,11 @@ Feature: Device Failure Scenarios
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with
| property | value |
| id | XXX-YYY |
| name | My Product |
| type | product |
| keys.0.key | AAA-CCC |
| keys.0.key | P.AAA-CCC |
| keys.0.type | product_id |
| keys.1.key | AAA-CCC |
| keys.1.key | P.AAA-CCC |
| keys.1.type | product_id |
Then the operation is not successful
And the error is DuplicateError
32 changes: 13 additions & 19 deletions feature_tests/domain/features/device.success.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ Feature: Device Success Scenarios
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with:
| property | value |
| id | <id> |
| name | <name> |
| type | <type> |
Then the operation is successful
And the result is a Device with
| property | value |
| id | <id> |
| name | <name> |
| type | <type> |
| status | active |
Expand All @@ -22,15 +20,14 @@ Feature: Device Success Scenarios
| DeviceCreatedEvent |
And event #1 of the result is DeviceCreatedEvent with
| property | value |
| id | <id> |
| name | <name> |
| type | <type> |
| status | active |
| ods_code | H8S7A |

Examples:
| id | name | type |
| XXX-YYY | My Product | product |
| name | type |
| My Product | product |

# | XXX-YYY | My API | service |
# | XXX-YYY | My Service | api |
Expand All @@ -40,40 +37,37 @@ Feature: Device Success Scenarios
| 00702d39-e65f-49f5-b9ef-6570245bfe17 | My Product Team | H8S7A |
When Product Team "00702d39-e65f-49f5-b9ef-6570245bfe17" creates a Device with:
| property | value |
| id | XXX-YYY |
| name | My Product |
| type | product |
| keys.0.key | AAA-CCC |
| keys.0.key | P.AAA-CCC |
| keys.0.type | product_id |
| keys.1.key | 12345 |
| keys.1.type | accredited_system_id |
Then the operation is successful
And the result is a Device with
| property | value |
| id | XXX-YYY |
| name | My Product |
| type | product |
| status | active |
| ods_code | H8S7A |
| keys.AAA-CCC.key | AAA-CCC |
| keys.AAA-CCC.type | product_id |
| keys.12345.key | 12345 |
| keys.12345.type | accredited_system_id |
| property | value |
| name | My Product |
| type | product |
| status | active |
| ods_code | H8S7A |
| keys.P#DOT#AAA-CCC.key | P.AAA-CCC |
| keys.P#DOT#AAA-CCC.type | product_id |
| keys.12345.key | 12345 |
| keys.12345.type | accredited_system_id |
And the following events were raised for the result
| event |
| DeviceCreatedEvent |
| DeviceKeyCreatedEvent |
| DeviceKeyCreatedEvent |
And event #1 of the result is DeviceCreatedEvent with
| property | value |
| id | XXX-YYY |
| name | My Product |
| type | product |
| status | active |
| ods_code | H8S7A |
And event #2 of the result is DeviceKeyAddedEvent with
| property | value |
| key | AAA-CCC |
| key | P.AAA-CCC |
| type | product_id |
And event #3 of the result is DeviceKeyAddedEvent with
| property | value |
Expand Down
1 change: 1 addition & 0 deletions feature_tests/domain/steps/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def _read_value(obj, path: list[str]) -> any:
)

head, *tail = path
head = head.replace("#DOT#", ".")
if isinstance(obj, dict):
obj = obj[head]
else:
Expand Down
Loading

0 comments on commit 2e62de9

Please sign in to comment.