def test_new_base_route(): # note default slashing behavior rp = BaseRoute('/a/b/<t:int>/thing/<das+int>') d = rp.match_path('/a/b/1/thing/1/2/3/4') yield eq_, d, {u't': 1, u'das': [1, 2, 3, 4]} d = rp.match_path('/a/b/1/thing/hi/') yield eq_, d, None d = rp.match_path('/a/b/1/thing/') yield eq_, d, None rp = BaseRoute('/a/b/<t:int>/thing/<das*int>', methods=['GET']) d = rp.match_path('/a/b/1/thing') yield eq_, d, {u't': 1, u'das': []}
def test_base_route_executes(): br = BaseRoute('/', lambda request: request['stephen']) res = br.execute({'stephen': 'laporte'}) yield eq_, res, 'laporte'
def test_base_application_basics(): br = BaseRoute('/', lambda request: BaseResponse('lolporte')) ba = BaseApplication([br]) client = Client(ba, BaseResponse) res = client.get('/') yield eq_, res.data, 'lolporte'
def test_base_route_raises_on_no_ep(): BaseRoute('/a/b/<t:int>/thing/<das+int>').execute({})
def test_base_route_executes(): br = BaseRoute('/', lambda request: request['stephen']) res = br.execute({'stephen': 'laporte'}) assert res == 'laporte'