Skip to content

Commit

Permalink
! _design/Stop to _design/Stops and
Browse files Browse the repository at this point in the history
  _design/Timetable to _design/Timetables
! timetables by line reduce function
ack above changes to cucumber features
  • Loading branch information
Stanley committed Jul 3, 2011
1 parent d0268c2 commit 40f6ca7
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 88 deletions.
42 changes: 21 additions & 21 deletions features/stops_design.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: List stops
| 1 | Bagatela | Dunajewskiego |
| 2 | Bagatela | Karmelicka |
| 3 | Bagatela | Podwale |
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_view/by_name?key=["Bagatela","Karmelicka"]
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_view/by_name?key=["Bagatela","Karmelicka"]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand All @@ -30,7 +30,7 @@ Feature: List stops
| 1 | Bagatela | Dunajewskiego |
| 2 | Bagatela | Karmelicka |
| 3 | Bagatela | Podwale |
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_view/by_name?startkey=["Bagatela"]&endkey=["Bagatela",{}]
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_view/by_name?startkey=["Bagatela"]&endkey=["Bagatela",{}]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand All @@ -42,7 +42,7 @@ Feature: List stops
"""

Scenario: Attempt to find stops which do not exist
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_view/by_name?startkey=["Utopia"]&endkey=["Utopia",{}]
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_view/by_name?startkey=["Utopia"]&endkey=["Utopia",{}]
Then the response status should be 200
And the response should be:
"""
Expand All @@ -68,20 +68,20 @@ Feature: List stops
| 12 | Flisacka |
| 13 | Salvator |
And the following timetables:
| _id | stop | stop_id | line | destination | source |
| 14 | Cmentarz Rakowicki | 1 | 2 | SALWATOR | a |
| 15 | Cmentarz Rakowicki | 2 | 2 | SALWATOR | b |
| 16 | Rakowiecka | 3 | 2 | SALWATOR | c |
| 17 | Uniwersytet Ekonomiczny | 4 | 2 | SALWATOR | d |
| 18 | Lubicz | 5 | 2 | SALWATOR | e |
| 19 | Dworzec Główny | 6 | 2 | SALWATOR | f |
| 20 | Basztowa LOT | 7 | 2 | SALWATOR | g |
| 21 | Teatr Bagatela | 8 | 2 | SALWATOR | h |
| 22 | Filharmonia | 9 | 2 | SALWATOR | i |
| 23 | Jubilat | 10 | 2 | SALWATOR | j |
| 24 | Komorowskiego | 11 | 2 | SALWATOR | k |
| 25 | Flisacka | 12 | 2 | SALWATOR | l |
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_view/by_line?startkey=["2", "SALWATOR"]&endkey=["2", "SALWATOR", {}]&include_docs=true
| _id | stop | stop_id | line | route | source |
| 14 | Cmentarz Rakowicki | 1 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | a |
| 15 | Cmentarz Rakowicki | 2 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | b |
| 16 | Rakowiecka | 3 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | c |
| 17 | Uniwersytet Ekonomiczny | 4 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | d |
| 18 | Lubicz | 5 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | e |
| 19 | Dworzec Główny | 6 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | f |
| 20 | Basztowa LOT | 7 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | g |
| 21 | Teatr Bagatela | 8 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | h |
| 22 | Filharmonia | 9 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | i |
| 23 | Jubilat | 10 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | j |
| 24 | Komorowskiego | 11 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | k |
| 25 | Flisacka | 12 | 2 | CMENTARZ - Rakowicka, Lubicz - SALWATOR | l |
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_view/by_line?startkey=["2", "SALWATOR"]&endkey=["2", "SALWATOR", {}]&include_docs=true
Then the response status should be 200
And the response without rows' doc._rev should be:
"""
Expand Down Expand Up @@ -113,7 +113,7 @@ Feature: List stops
| L | 1 | OSTATNI |
| L | 2 | OSTATNI |
| L | 3 | OSTATNI |
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_list/polyline/by_line?startkey=["L", "OSTATNI"]&endkey=["L", "OSTATNI", {}]&include_docs=true
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_list/polyline/by_line?startkey=["L", "OSTATNI"]&endkey=["L", "OSTATNI", {}]&include_docs=true
Then the response status should be 200
And the response should be:
"""
Expand All @@ -127,11 +127,11 @@ Feature: List stops

Scenario: Attributes filtering
Given the following stops:
| _id | name | lat | lng | address |
| _id | name | lat | lng | address |
| 1 | Bagatela | 50.06380081 | 19.93320084 | Dunajewskiego |
| 2 | Bagatela | 50.0637207 | 19.93255997 | Karmelicka |
| 3 | Bagatela | 50.06309891 | 19.9326992 | Podwale |
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_list/filter/by_name?startkey=["Bagatela"]&endkey=["Bagatela",{}]&only=lat,lng
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_list/filter/by_name?startkey=["Bagatela"]&endkey=["Bagatela",{}]&only=lat,lng
Then the response status should be 200
And the response should be:
"""
Expand All @@ -141,7 +141,7 @@ Feature: List stops
{"id":"3","key":["Bagatela","Podwale"],"value":{"lat":"50.06309891","lng":"19.9326992"}}
]}
"""
When I send a GET request to http://api.bagate.la/kr/_design/Stop/_list/filter/by_name?startkey=["Bagatela"]&endkey=["Bagatela",{}]&except=_rev,lat,lng
When I send a GET request to http://api.bagate.la/kr/_design/Stops/_list/filter/by_name?startkey=["Bagatela"]&endkey=["Bagatela",{}]&except=_rev,lat,lng
Then the response status should be 200
And the response should be:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'uri'
require 'yajl'
require 'json'
require 'rest_client'
require 'rake'

Expand Down
57 changes: 26 additions & 31 deletions features/timetables_design.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: List timetables
| 11 | 13.10.2010 | Komorowskiego | 2 | CMENTARZ RAKOWICKI - SALWATOR | /0002/0002t022.htm |
| 12 | 13.10.2010 | Flisacka | 2 | CMENTARZ RAKOWICKI - SALWATOR | /0002/0002t023.htm |

When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_line?startkey=["2","SALWATOR"]&endkey=["2","SALWATOR",{}]&reduce=false
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_line?startkey=["2","SALWATOR"]&endkey=["2","SALWATOR",{}]&reduce=false
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand Down Expand Up @@ -182,36 +182,31 @@ Feature: List timetables

Scenario: Lines' route(s)
Given the following timetables:
| stop | line | route | source |
| Prądnik Czerwony | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t001.htm |
| Powstańców Garaże | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t002.htm |
| Powstańców | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t003.htm |
| Majora | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t004.htm |
| Al. 29 Listopada | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t005.htm |
| Opolska Estrada | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t006.htm |
| Uniwersytet Rolniczy | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t007.htm |
| Biskupa Prandoty | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t008.htm |
| Cmentarz | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t009.htm |
| Politechnika | 105 | PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t010.htm |
| Cmentarz Batowice | 105 | CMENTARZ BATOWICE - Powstańców, Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t022.htm |
| Cmentarz Batowice | 105 | CMENTARZ BATOWICE - Powstańców, Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA) | /0105/0105t023.htm |
| Koniec Świata | 101 | | |
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_line?startkey=["105"]&group=true&group_level=2
| stop | line | route | source |
| Aleja Przyjaźni | 110 | ALEJA PRZYJAŹNI - WADÓW TUNEL | /0110/0110t001.htm |
| Aleja Róż | 110 | ALEJA PRZYJAŹNI - WADÓW TUNEL | /0110/0110t001.htm |
| Żeromskiego | 110 | ALEJA PRZYJAŹNI - WADÓW TUNEL | /0110/0110t001.htm |
| Teatr Ludowy | 110 | ALEJA PRZYJAŹNI - WADÓW TUNEL | /0110/0110t001.htm |
| Kocmyrzowska | 110 | ALEJA PRZYJAŹNI - WADÓW TUNEL | /0110/0110t001.htm |
| Bieńczyce Mleczarnia | 110 | ALEJA PRZYJAŹNI - WADÓW TUNEL | /0110/0110t001.htm |
| Wadów Działki (NŻ) | 110 | ALEJA PRZYJAŹNI - WĘGRZYNOWICE | /0110/0110t033.htm |
| Parowozownia (NŻ) | 110 | ALEJA PRZYJAŹNI - WĘGRZYNOWICE | /0110/0110t034.htm |
| Węgrzynowice I (NŻ) | 110 | ALEJA PRZYJAŹNI - WĘGRZYNOWICE | /0110/0110t035.htm |
| Węgrzynowice II (NŻ) | 110 | ALEJA PRZYJAŹNI - WĘGRZYNOWICE | /0110/0110t036.htm |

When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_line?group_level=1&startkey=["110"]
Then the response status should be 200
And the response should be:
"""
{"rows": [
{"key": ["105", "DWORZEC GŁÓWNY ZACHÓD (GALERIA)"], "value": ["105", [
"PRĄDNIK CZERWONY - Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA)",
"CMENTARZ BATOWICE - Powstańców, Strzelców, Powstańców, Majora, Dobrego Pasterza, Al. 29 Listopada, Pawia - DWORZEC GŁÓWNY ZACHÓD (GALERIA)"
]]}]}
{"key": ["110"], "value": 10}]}
"""
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_line?group=false
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_line?group_level=2&startkey=["110","WĘGRZYNOWICE"]&endkey=["110","WĘGRZYNOWICE",{}]
Then the response status should be 200
And the response should be:
"""
{"rows": [
{"key": null, "value": ["105", "101"]}
{"key": ["110","WĘGRZYNOWICE"], "value": 4}
]}
"""

Expand All @@ -226,7 +221,7 @@ Feature: List timetables
| 2 | Bagatela | 1 | {} |
| 3 | Bagatela | 1 | {} |
| 4 | Bagatela | 1 | {} |
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_stop_id?startkey=["1"]&endkey=["1",{}]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_stop_id?startkey=["1"]&endkey=["1",{}]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand All @@ -246,7 +241,7 @@ Feature: List timetables
]}
"""

When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_stop_id?key=["1",1]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_stop_id?key=["1",1]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand Down Expand Up @@ -277,7 +272,7 @@ Feature: List timetables
| 5 | 14 | Bagatela | 2 | BRONOWICE - Bronowicka, Podchorążych, Królewska, Karmelicka, Basztowa, Lubicz, Al. Powstania Warszawskiego, Al. Pokoju, Bieńczycka, Andersa, Broniewskiego, Mikołajczyka, Srebrnych Orłów, ks. Jancarza - MISTRZEJOWICE | {} |
| 6 | 15 | Bagatela | 3 | CICHY KĄCIK - Al. 3 Maja, Podwale, Basztowa, Lubicz, Mogilska, Al. Jana Pawła II, Ptaszyckiego, Igołomska - PLESZÓW | {} |
| 7 | 15 | Bagatela | 1 | PLESZÓW - Igołomska, Ptaszyckiego, Al. Jana Pawła II, Mogilska, Lubicz, Basztowa, Dunajewskiego, Piłsudskiego, Al. 3 Maja - CICHY KĄCIK | {} |
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_stop?startkey=["Bagatela"]&endkey=["Bagatela",{}]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_stop?startkey=["Bagatela"]&endkey=["Bagatela",{}]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand Down Expand Up @@ -334,7 +329,7 @@ Feature: List timetables
}
"""
# Find timetables by stop name and line number
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_stop?startkey=["Bagatela",14]&endkey=["Bagatela",14,{}]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_stop?startkey=["Bagatela",14]&endkey=["Bagatela",14,{}]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand Down Expand Up @@ -365,7 +360,7 @@ Feature: List timetables
"type": "Timetable"}}]}
"""
# Find one timetable by stop name, line number and it's destination
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_stop?key=["Bagatela",14,"BRONOWICE"]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_stop?key=["Bagatela",14,"BRONOWICE"]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand Down Expand Up @@ -393,7 +388,7 @@ Feature: List timetables
| 1 | http://rozklady.mpk.krakow.pl/aktualne/0099/0099t014.htm | 17.04.2011 |
| 2 | http://rozklady.mpk.krakow.pl/aktualne/0099/0099t014.htm | 17.05.2011 |
| 3 | http://rozklady.mpk.krakow.pl/aktualne/0099/0099t030.htm | 17.05.2011 |
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_source?key=["http://rozklady.mpk.krakow.pl/aktualne/0099/0099t030.htm", "17.05.2011"]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_source?key=["http://rozklady.mpk.krakow.pl/aktualne/0099/0099t030.htm", "17.05.2011"]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand All @@ -403,7 +398,7 @@ Feature: List timetables
"value": {"_id":"3", "source": "http://rozklady.mpk.krakow.pl/aktualne/0099/0099t030.htm", "valid_from": "17.05.2011", "type": "Timetable"}}]}
"""
# Znajdź wszystkie (również nieaktualne) rozkłady jazdy uzyskane z danego źródła.
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_view/by_source?startkey=["http://rozklady.mpk.krakow.pl/aktualne/0099/0099t014.htm"]&endkey=["http://rozklady.mpk.krakow.pl/aktualne/0099/0099t014.htm", {}]
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_view/by_source?startkey=["http://rozklady.mpk.krakow.pl/aktualne/0099/0099t014.htm"]&endkey=["http://rozklady.mpk.krakow.pl/aktualne/0099/0099t014.htm", {}]
Then the response status should be 200
And the response without rows' value._rev should be:
"""
Expand All @@ -422,15 +417,15 @@ Feature: List timetables
Given the following timetables:
| _id | line | route | stop | table | valid_since |
| 1 | 1 | WZGÓRZA KRZESŁAWICKIE - Kocmyrzowska, Bieńczycka, Al. Pokoju, Grzegórzecka, Dietla, Starowiślna - POCZTA GŁÓWNA | Darwina | {"Soboty": {"5": ["15","35"]}} | 14.10.2010 |
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_list/filter/by_stop?only=line,stop
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_list/filter/by_stop?only=line,stop
Then the response status should be 200
And the response should be:
"""
{"total_rows": 1, "offset": 0, "rows": [
{"id": "1", "key": ["Darwina", 1, "POCZTA GŁÓWNA"], "value": {"stop": "Darwina", "line": "1"}}
]}
"""
When I send a GET request to http://api.bagate.la/kr/_design/Timetable/_list/filter/by_stop?except=_id,_rev,route,table
When I send a GET request to http://api.bagate.la/kr/_design/Timetables/_list/filter/by_stop?except=_id,_rev,route,table
Then the response status should be 200
And the response should be:
"""
Expand Down
Loading

0 comments on commit 40f6ca7

Please sign in to comment.