Skip to content

Commit

Permalink
make python starting code smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
emilybache committed Aug 13, 2013
1 parent 2db8b39 commit 9f41fe5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
train/*
trains/*
*.pyc

6 changes: 4 additions & 2 deletions guiding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@
class TrainReservationTest(unittest.TestCase):

def test_reserve_seats_via_POST(self):
form_data = {"train_id": "express_2000", "seats": 4}
form_data = {"train_id": "express_2000", "seat_count": 4}
data = urllib.parse.urlencode(form_data)

req = urllib.request.Request(url + "/reserve", bytes(data, encoding="ISO-8859-1"))
response = urllib.request.urlopen(req).read().decode("ISO-8859-1")
reservation = json.loads(response)

assert "express_2000" == reservation["train_id"]
assert 4 == len(reservation["seats"])
assert "1A" == reservation["seats"][0]
assert "75bcd15" == reservation["booking_reference"]


def test_reserve_seats_via_cmd(self):
def hid_test_reserve_seats_via_cmd(self):
response = subprocess.check_output([interpreter, reservation_script, "express2000", "4"], stderr=subprocess.STDOUT, universal_newlines = True)
reservation = json.loads(response)

assert "express_2000" == reservation["train_id"]
assert 4 == len(reservation["seats"])
assert "1A" == reservation["seats"][0]
assert "75bcd15" == reservation["booking_reference"]
16 changes: 0 additions & 16 deletions python/reservations.py

This file was deleted.

21 changes: 0 additions & 21 deletions python/test_train_reservation.py

This file was deleted.

13 changes: 7 additions & 6 deletions python/ticket_office.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

from reservations import *

class TicketOffice(object):

def __init__(self, train_data_service, booking_reference_service):
pass

def make_reservation(self, reservation_request):
def reserve(self, train_id, seat_count):
# TODO: write this code!
pass

if __name__ == "__main__":
"""Deploy this class as a web service using CherryPy"""
import cherrypy
TicketOffice.reserve.exposed = True
cherrypy.config.update({"server.socket_port" : 8083})
cherrypy.quickstart(TicketOffice())

0 comments on commit 9f41fe5

Please sign in to comment.