def test_post(self): sr = FixCreateResource() res = sr.post() self.assertEqual(res.status_code, 201) sr1 = FixResource() fix = Fix.from_json(res.data) sr1.delete(str(fix.id))
def test_get_right(self): scr = FixCreateResource() sr = FixResource() res = scr.post() fix = Fix.from_json(res.data) res = sr.get(str(fix.id)) self.assertEqual(res.status_code, 200) sr.delete(str(fix.id))
def test_patch_add_right(self): sr = FixResource() scr = FixCreateResource() res = scr.post() fix = Fix.from_json(res.data) mr = MechanicResource() mcr = MechanicCreateResource() resm = mcr.post() meh = Mechanic.from_json(resm.data) payload = {'meh_id': meh.id, 'status': 'mehadd'} res = requests.patch(current_config.GATEWAY_URL + current_config.GATEWAY_PATH + '/fixes/add' + '/%s' % fix.id, data=jsonpickle.encode(payload)) self.assertEqual(res.status_code, 201) sr.delete(str(fix.id)) mr.delete(str(meh.id))
def test_delete_right(self): sr = FixResource() ur = UserResource() scr = FixCreateResource() r = scr.post() fix = Fix.from_json(r.data) u = UserCreateResource() us = u.post() user = User.from_json(us.data) payload = {'fix_id': fix.id, 'name': 'suzuki', 'user_id': user.id} res = requests.post(current_config.GATEWAY_URL + current_config.GATEWAY_PATH + '/cars/add', data=jsonpickle.encode(payload)) #sr.delete(fix.id) car = Car.from_json(res.content) ret_prod = GatewayReturnCar() res = ret_prod.delete(car.id) self.assertEqual(res.status_code, 204) ur.delete(user.id) sr.delete(fix.id)