-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(test-data-generator): Output required Test Interface Actions #657
Changes from all commits
76ce6ef
71717f3
17098aa
75893b0
7e537d6
e74c9f8
07cc936
52ccbca
e9d109c
3b2d6c3
93f307b
81037e2
c3a88c2
7dcfc7a
c8598a7
dc83f0c
eb4f4bc
e325796
79bcf75
81ecc5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
test-data/test-data.json | ||
output/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,15 @@ | |
|
||
Command line tool to generate a distribution definition of test data based on the configured features. | ||
|
||
Test data is outputted to `./test-data/test-data.json` by default. | ||
The data outputted by this tool can be used for the following purposes: | ||
|
||
The data outputted by this tool can be used by a script to add sufficient test data into your [Open Booking API](https://openactive.io/open-booking-api/EditorsDraft/) implementation's database for testing when using [random mode](../README.md#userandomopportunities). | ||
- Used by a script to add sufficient test data into your [Open Booking API](https://openactive.io/open-booking-api/EditorsDraft/) implementation's database for testing when using [random mode](../README.md#userandomopportunities). | ||
- Used to determine which [Test Interface Actions](https://openactive.io/test-interface/#actions-endpoint) (e.g. `test:AttendeeAbsentSimulateAction`) are required to be supported by your [Open Booking API](https://openactive.io/open-booking-api/EditorsDraft/) implementation. | ||
|
||
Test data is outputted to the following files by default: | ||
|
||
- `./output/opportunity-test-data.json` ([more info](#opportunity-test-datajson-file-format)) | ||
- `./output/test-interface-actions.json` ([more info](#test-interface-actionsjson-file-format)) | ||
|
||
## Usage | ||
|
||
|
@@ -13,10 +19,12 @@ npm run test-data-generator # all active features specified in the current confi | |
|
||
npm run test-data-generator -- common-error-conditions # only enough data for the common-error-conditions feature | ||
|
||
npm run test-data-generator -- --output ./test-data.json # output to ./test-data.json | ||
npm run test-data-generator -- --output-dir ../../../test-data-generator-output # output to ../../../test-data-generator-output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep makes sense |
||
``` | ||
|
||
## Test data file format | ||
## `opportunity-test-data.json` file format | ||
|
||
This file can be used by a script to add sufficient test data into your [Open Booking API](https://openactive.io/open-booking-api/EditorsDraft/) implementation's database for testing when using [random mode](../README.md#userandomopportunities). | ||
|
||
The `item` within the file format is identical to the Controlled Opportunity Creation endpoint defined within the [OpenActive Test Interface](https://openactive.io/test-interface/). This allows an implementation to use the same logic to generate data from the test data file and from the test interface. | ||
|
||
|
@@ -71,19 +79,50 @@ The `item` within the file format is identical to the Controlled Opportunity Cre | |
} | ||
``` | ||
|
||
## `test-interface-actions.json` file format | ||
|
||
This file can be used to determine which [Test Interface Actions](https://openactive.io/test-interface/#actions-endpoint) (e.g. `test:AttendeeAbsentSimulateAction`) are required to be supported by your [Open Booking API](https://openactive.io/open-booking-api/EditorsDraft/) implementation. | ||
|
||
This example shows that the `test:AccessChannelUpdateSimulateAction` and `test:AccessCodeUpdateSimulateAction` [Test Interface Actions](https://openactive.io/test-interface/#actions-endpoint) need to be implemented. | ||
|
||
```json | ||
{ | ||
"@context": [ | ||
"https://openactive.io/", | ||
"https://openactive.io/test-interface" | ||
], | ||
"@type": "ItemList", | ||
"numberOfItems": 2, | ||
"itemListElement": [ | ||
{ | ||
"@type": "ListItem", | ||
"item": { | ||
"@type": "test:AccessChannelUpdateSimulateAction" | ||
} | ||
}, | ||
{ | ||
"@type": "ListItem", | ||
"item": { | ||
"@type": "test:AccessCodeUpdateSimulateAction" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Use with reference implementation in development | ||
|
||
Run the generator: | ||
```bash | ||
$ npm run test-data-generator | ||
|
||
Test data file created containing a distribution with 482 items: | ||
/example/path/test-data/test-data.json | ||
/example/path/output/opportunity-test-data.json | ||
``` | ||
|
||
Take the output path, and set the environment variable `OpenActiveTestDataFile` in `AppSettings.Development.json`: | ||
```json | ||
"OpenActiveTestDataFile": "/example/path/test-data/test-data.json" | ||
"OpenActiveTestDataFile": "/example/path/output/opportunity-test-data.json" | ||
``` | ||
|
||
``` | ||
|
@@ -94,6 +133,6 @@ dotnet run | |
|
||
```bash | ||
npm run test-data-generator | ||
export OpenActiveTestDataFile=/example/path/test-data/test-data.json | ||
export OpenActiveTestDataFile=/example/path/output/opportunity-test-data.json | ||
dotnet run | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed because it now contains more info. But this new info (required TI Actions) is still per-feature. So, feature-requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the reviewer is not aware, Test Data Generator gets its metadata from this file which is generated during automatic documentation generation (which has access to each test's describeFeature(..) metadata)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the rename very much!