Command line tool to generate a distribution definition of test data based on the configured features.
The data outputted by this tool can be used for the following purposes:
- Used by a script to add sufficient test data into your Open Booking API implementation's database for testing when using random mode.
- Used to determine which Test Interface Actions (e.g.
test:AttendeeAbsentSimulateAction
) are required to be supported by your Open Booking API implementation.
Test data is outputted to the following files by default:
npm run test-data-generator # all active features specified in the current config
npm run test-data-generator -- common-error-conditions # only enough data for the common-error-conditions feature
npm run test-data-generator -- --output-dir ../../../test-data-generator-output # output to ../../../test-data-generator-output
This file can be used by a script to add sufficient test data into your Open Booking API implementation's database for testing when using random mode. A guide on how to do this can be found in the Developer Docs: Random Mode: Generating Test Opportunity Data.
The item
within the file format is identical to the Controlled Opportunity Creation endpoint defined within the OpenActive Test Interface. This allows an implementation to use the same logic to generate data from the test data file and from the test interface.
{
"@context": [
"https://openactive.io/",
"https://openactive.io/test-interface"
],
"@type": "ItemList",
"numberOfItems": 123,
"itemListElement": [
{
"@type": "ListItem",
"item": {
"@type": "ScheduledSession",
"superEvent": {
"@type": "SessionSeries",
"organizer": {
"@type": "Organization",
"@id": "https://id.booking-system.example.com/organizer/3"
}
},
"test:testOpportunityCriteria": "https://openactive.io/test-interface#TestOpportunityBookable",
"test:testOpenBookingFlow": "https://openactive.io/test-interface#OpenBookingSimpleFlow",
"test:testOpportunityDataShapeExpression": [
{
"@type": "test:TripleConstraint",
"predicate": "https://schema.org/remainingAttendeeCapacity",
"valueExpr": {
"@type": "NumericNodeConstraint",
"mininclusive": 2
}
}
],
"test:testOfferDataShapeExpression": [
{
"@type": "test:TripleConstraint",
"predicate": "https://openactive.io/openBookingFlowRequirement",
"valueExpr": {
"@type": "test:ArrayConstraint",
"datatype": "oa:OpenBookingFlowRequirement",
"excludesAll": [
"https://openactive.io/OpenBookingApproval"
]
}
}
]
},
"test:numberOfInstancesInDistribution": 32
}
]
}
This file can be used to determine which Test Interface Actions (e.g. test:AttendeeAbsentSimulateAction
) are required to be supported by your Open Booking API implementation.
This example shows that the test:AccessChannelUpdateSimulateAction
and test:AccessCodeUpdateSimulateAction
Test Interface Actions need to be implemented.
{
"@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"
}
}
]
}
Run the generator:
$ npm run test-data-generator
Test data file created containing a distribution with 482 items:
/example/path/output/opportunity-test-data.json
Take the output path, and set the environment variable OpenActiveTestDataFile
in AppSettings.Development.json
:
"OpenActiveTestDataFile": "/example/path/output/opportunity-test-data.json"
dotnet run
npm run test-data-generator
export OpenActiveTestDataFile=/example/path/output/opportunity-test-data.json
dotnet run