def test_insert_supercar(): supercars[1] = {'engine': '1'} app = TestApp(restserver.default_app()) resp = app.post_json('/supercars', {'engine': '2'}) assert_equal(resp.status, '200 OK') assert_equal(supercars, {1: {'engine': '1'}, 2: {'engine': '2'}})
def test_delete_supercar(): supercars[1] = {'engine': '1'} app = TestApp(default_app()) resp = app.delete('/supercars/1') assert_equal(resp.status, '200 OK') app.reset()
def test_get_all_supercars(): supercars[1] = {'engine': '1'} app = TestApp(default_app()) resp = app.get('/supercars') assert_equal(resp.status, '200 OK') assert_equal(resp.json, [{'engine': '1'}])
def test_get_supercar(): supercars[1] = {'_id': '1'} app = TestApp(default_app()) resp = app.get('/supercars/1') assert_equal(resp.status, '200 OK') assert_equal(resp.json, {'_id': '1'})
def test_update_supercar(): supercars[1] = {'engine': '1'} app = TestApp(restserver.default_app()) # this MUST be json data! # resp = app.put('/supercars/1', json.dumps({'have_one': 'yes'}), content_type='application/json') # resp = app.put_json('/supercars/1', {'have_one': 'yes'}) resp = app.put('/supercars/1', '{"have_one": \n"yes"}', content_type='application/json') assert_equal(resp.status, '200 OK') assert_equal(supercars, {1: {'engine': '1', 'have_one': 'yes'}})
def test_get_image(): app = TestApp(restserver.default_app()) resp = app.get('/images/005.png') assert_equal(resp.status, '200 OK') assert_equal(resp.content_length, 115616)