forked from lechatquidanse/bicing-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstation_with_last_availability.feature
86 lines (83 loc) · 4.25 KB
/
station_with_last_availability.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# The availability (status, number of bike available and number of slot available).
Feature: View last availability for each stations to choose one to start or end my itinerary.
In order to select a station
As a client software API
I need to be able to retrieve a list composed by the last availabilit for each stations.
@database
Scenario: Can retrieve last availability for each stations.
Given station identified by "15cff96c-de06-4606-9870-b82eb9219339" with station states from "2018-09-17 15:52:51":
| stated_at | available_bike | available_slot | status |
| -5 minutes | 2 | 28 | OPENED |
| +5 minutes | 27 | 3 | CLOSED |
And station identified by "2d55ba4e-e0b0-4145-aff5-96426aee669b" with station states from "2018-09-17 15:52:51":
| stated_at | available_bike | available_slot | status |
| -5 minutes | 10 | 10 | OPENED |
| +5 minutes | 18 | 2 | OPENED |
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/api/last-availabilities-by-station"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
"""
{
"@context": "/api/contexts/last%20availability%20by%20station",
"@id": "/api/last-availabilities-by-station",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/api/last-availabilities-by-station/2d55ba4e-e0b0-4145-aff5-96426aee669b",
"@type": "last availability by station",
"id": "2d55ba4e-e0b0-4145-aff5-96426aee669b",
"statedAt": "2018-09-17 15:57:51",
"availableBikeNumber": 18,
"availableSlotNumber": 2,
"status": "OPENED"
},
{
"@id": "/api/last-availabilities-by-station/15cff96c-de06-4606-9870-b82eb9219339",
"@type": "last availability by station",
"id": "15cff96c-de06-4606-9870-b82eb9219339",
"statedAt": "2018-09-17 15:57:51",
"availableBikeNumber": 27,
"availableSlotNumber": 3,
"status": "CLOSED"
}
]
}
"""
@database
Scenario: Can retrieve last availability for a station that does not exists.
Given station identified by "15cff96c-de06-4606-9870-b82eb9219339" with station states from "2018-09-17 15:52:51":
| stated_at | available_bike | available_slot | status |
| -5 minutes | 2 | 28 | OPENED |
| +5 minutes | 27 | 3 | CLOSED |
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/api/last-availabilities-by-station/15cff96c-de06-4606-9870-b82eb9219339"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON should be equal to:
"""
{
"@context": "/api/contexts/last%20availability%20by%20station",
"@id": "/api/last-availabilities-by-station/15cff96c-de06-4606-9870-b82eb9219339",
"@type": "last availability by station",
"id": "15cff96c-de06-4606-9870-b82eb9219339",
"statedAt": "2018-09-17 15:57:51",
"availableBikeNumber": 27,
"availableSlotNumber": 3,
"status": "CLOSED"
}
"""
@database
Scenario: Can not retrieve last availability for a station that does not exists.
Given station identified by "15cff96c-de06-4606-9870-b82eb9219339" with station states from "2018-09-17 15:52:51":
| stated_at | available_bike | available_slot | status |
| -5 minutes | 2 | 28 | OPENED |
| +5 minutes | 27 | 3 | CLOSED |
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/api/last-availabilities-by-station/2d55ba4e-e0b0-4145-aff5-96426aee669b"
Then the response status code should be 404
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"