-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from tdelmas/better-conditionnal
Add conditional requirement
- Loading branch information
Showing
31 changed files
with
3,884 additions
and
260 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
gbfs-validator/__test__/fixtures/conditionnal_no_vehicle_type_id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const fastify = require('fastify') | ||
|
||
function build(opts = {}) { | ||
const app = fastify(opts) | ||
|
||
app.get('/gbfs.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
en: { | ||
feeds: [ | ||
{ | ||
name: 'system_information', | ||
url: `http://${request.hostname}/system_information.json` | ||
}, | ||
{ | ||
name: 'station_information', | ||
url: `http://${request.hostname}/station_information.json` | ||
}, | ||
{ | ||
name: 'station_status', | ||
url: `http://${request.hostname}/station_status.json` | ||
}, | ||
{ | ||
name: 'free_bike_status', | ||
url: `http://${request.hostname}/free_bike_status.json` | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}) | ||
|
||
app.get('/system_information.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
system_id: 'shared_bike', | ||
language: 'en', | ||
name: 'Shared Bike USA', | ||
timezone: 'UTC' | ||
} | ||
} | ||
}) | ||
|
||
app.get('/free_bike_status.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
bikes: [ | ||
{ | ||
bike_id: 'bike1', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false | ||
}, | ||
{ | ||
bike_id: 'bike2', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false, | ||
vehicle_type_id: 'abc123' | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
return app | ||
} | ||
|
||
module.exports = build |
141 changes: 141 additions & 0 deletions
141
gbfs-validator/__test__/fixtures/conditionnal_vehicle_type_id.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
const fastify = require('fastify') | ||
|
||
function build(opts = {}) { | ||
const app = fastify(opts) | ||
|
||
app.get('/gbfs.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
en: { | ||
feeds: [ | ||
{ | ||
name: 'system_information', | ||
url: `http://${request.hostname}/system_information.json` | ||
}, | ||
{ | ||
name: 'station_information', | ||
url: `http://${request.hostname}/station_information.json` | ||
}, | ||
{ | ||
name: 'station_status', | ||
url: `http://${request.hostname}/station_status.json` | ||
}, | ||
{ | ||
name: 'free_bike_status', | ||
url: `http://${request.hostname}/free_bike_status.json` | ||
}, | ||
{ | ||
name: 'vehicle_types', | ||
url: `http://${request.hostname}/vehicle_types.json` | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}) | ||
|
||
app.get('/system_information.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
system_id: 'shared_bike', | ||
language: 'en', | ||
name: 'Shared Bike USA', | ||
timezone: 'UTC' | ||
} | ||
} | ||
}) | ||
|
||
app.get('/vehicle_types.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
vehicle_types: [ | ||
{ | ||
vehicle_type_id: 'abc123', | ||
form_factor: 'bicycle', | ||
propulsion_type: 'human', | ||
name: 'Example Basic Bike', | ||
default_reserve_time: 30, | ||
return_type: ['any_station', 'free_floating'], | ||
vehicle_assets: { | ||
icon_url: 'https://www.example.com/assets/icon_bicycle.svg', | ||
icon_url_dark: | ||
'https://www.example.com/assets/icon_bicycle_dark.svg', | ||
icon_last_modified: '2021-06-15' | ||
}, | ||
default_pricing_plan_id: 'bike_plan_1', | ||
pricing_plan_ids: ['bike_plan_1', 'bike_plan_2', 'bike_plan_3'] | ||
}, | ||
{ | ||
vehicle_type_id: 'efg456', | ||
form_factor: 'car', | ||
propulsion_type: 'electric', | ||
name: 'Example Electric Car', | ||
default_reserve_time: 30, | ||
max_range_meters: 100, | ||
return_type: ['any_station', 'free_floating'], | ||
vehicle_assets: { | ||
icon_url: 'https://www.example.com/assets/icon_car.svg', | ||
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg', | ||
icon_last_modified: '2021-06-15' | ||
}, | ||
default_pricing_plan_id: 'car_plan_1', | ||
pricing_plan_ids: ['car_plan_1', 'car_plan_2', 'car_plan_3'] | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
app.get('/free_bike_status.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
bikes: [ | ||
{ | ||
bike_id: 'bike1', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false | ||
// missing vehicle_type_id | ||
}, | ||
{ | ||
bike_id: 'bike2', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false, | ||
vehicle_type_id: 'abc123' | ||
}, | ||
{ | ||
bike_id: 'car1', | ||
last_reported: 1609866109, | ||
lat: 12.345678, | ||
lon: 56.789012, | ||
is_reserved: false, | ||
is_disabled: false, | ||
vehicle_type_id: 'efg456' | ||
// missing current_range_meters | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
return app | ||
} | ||
|
||
module.exports = build |
132 changes: 132 additions & 0 deletions
132
gbfs-validator/__test__/fixtures/conditionnal_vehicle_types_available.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
const fastify = require('fastify') | ||
|
||
function build(opts = {}) { | ||
const app = fastify(opts) | ||
|
||
app.get('/gbfs.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
en: { | ||
feeds: [ | ||
{ | ||
name: 'system_information', | ||
url: `http://${request.hostname}/system_information.json` | ||
}, | ||
{ | ||
name: 'station_information', | ||
url: `http://${request.hostname}/station_information.json` | ||
}, | ||
{ | ||
name: 'station_status', | ||
url: `http://${request.hostname}/station_status.json` | ||
}, | ||
{ | ||
name: 'vehicle_types', | ||
url: `http://${request.hostname}/vehicle_types.json` | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}) | ||
|
||
app.get('/system_information.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
system_id: 'shared_bike', | ||
language: 'en', | ||
name: 'Shared Bike USA', | ||
timezone: 'UTC' | ||
} | ||
} | ||
}) | ||
|
||
app.get('/vehicle_types.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
vehicle_types: [ | ||
{ | ||
vehicle_type_id: 'abc123', | ||
form_factor: 'bicycle', | ||
propulsion_type: 'human', | ||
name: 'Example Basic Bike', | ||
default_reserve_time: 30, | ||
return_type: ['any_station', 'free_floating'], | ||
vehicle_assets: { | ||
icon_url: 'https://www.example.com/assets/icon_bicycle.svg', | ||
icon_url_dark: | ||
'https://www.example.com/assets/icon_bicycle_dark.svg', | ||
icon_last_modified: '2021-06-15' | ||
}, | ||
default_pricing_plan_id: 'bike_plan_1', | ||
pricing_plan_ids: ['bike_plan_1', 'bike_plan_2', 'bike_plan_3'] | ||
}, | ||
{ | ||
vehicle_type_id: 'efg456', | ||
form_factor: 'car', | ||
propulsion_type: 'electric', | ||
name: 'Example Electric Car', | ||
default_reserve_time: 30, | ||
max_range_meters: 100, | ||
return_type: ['any_station', 'free_floating'], | ||
vehicle_assets: { | ||
icon_url: 'https://www.example.com/assets/icon_car.svg', | ||
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg', | ||
icon_last_modified: '2021-06-15' | ||
}, | ||
default_pricing_plan_id: 'car_plan_1', | ||
pricing_plan_ids: ['car_plan_1', 'car_plan_2', 'car_plan_3'] | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
app.get('/station_status.json', async function(request, reply) { | ||
return { | ||
last_updated: 1566224400, | ||
ttl: 0, | ||
version: '2.2', | ||
data: { | ||
stations: [ | ||
{ | ||
station_id: 'abc123', | ||
num_bikes_available: 0, | ||
is_installed: true, | ||
is_renting: true, | ||
is_returning: true, | ||
last_reported: 1566224400 | ||
// missing vehicle_types_available | ||
}, | ||
{ | ||
station_id: 'abc123', | ||
num_bikes_available: 0, | ||
is_installed: true, | ||
is_renting: true, | ||
is_returning: true, | ||
last_reported: 1566224400, | ||
vehicle_types_available: [ | ||
{ | ||
vehicle_type_id: 'efg456', | ||
count: 2 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
|
||
return app | ||
} | ||
|
||
module.exports = build |
Oops, something went wrong.