def put(self, case_id): if not id_is_valid(case_id): return {"message": "bad request"}, 400 db = Database(MAGIC_DB) case = db.get_case(case_id) if len(case) > 0: data = Case.parser.parse_args() dictionary_steps = self.parse_steps(data['steps']) print(dictionary_steps) db.update_case(case_id, data['name'], json.dumps(dictionary_steps)) return 200
def get(self, case_id): if not id_is_valid(case_id): return {"message": "bad request"}, 400 db = Database(MAGIC_DB) case = db.get_case(case_id) if len(case) > 0: return_case = { "case_id": case[0][0], "name": case[0][1], "steps": json.loads(case[0][2]) } return jsonify(return_case)
def get(self, suite_id): if not id_is_valid(suite_id): return {"message": "bad request"}, 400 db = Database(MAGIC_DB) suite = db.get_suite(suite_id) if len(suite) > 0: return_suite = { "suite_id": suite[0][0], "name": suite[0][1], "cases": suite[0][2] } return jsonify(return_suite) else: return {"message": "Item not found"}, 404
def delete(self, case_id): if not id_is_valid(case_id): return {"message": "bad request"}, 400 db = Database(MAGIC_DB) db.delete_case(case_id) return 200
def test_id_is_valid_negative(self): is_valid = helpers.id_is_valid(-1) self.assertEqual(False, is_valid, "Expected id_is_valid(-1) to be False")
def test_id_is_valid_int(self): is_valid = helpers.id_is_valid(1) self.assertEqual(True, is_valid, "Expected id_is_valid(1) to be True")
def test_id_is_valid_float(self): is_valid = helpers.id_is_valid(1.0) self.assertEqual(False, is_valid, "Expected id_is_valid(1.0) to be False")
def test_id_is_valid_string(self): is_valid = helpers.id_is_valid("1") self.assertEqual(False, is_valid, "Expected id_is_valid(\"1\") to be False")