def testAfterApply(self): extension_apply_11 = ExtensionApply11Model(student=self.student, class_=1, seat=15).save() extension_apply_12 = ExtensionApply12Model(student=self.student, class_=3, seat=13).save() goingout_apply = GoingoutApplyModel(student=self.student, on_saturday=True, on_sunday=False).save() stay_apply = StayApplyModel(student=self.student, value=1).save() # (1) 신청 정보 확인 resp = self._request() # (2) status code 200 self.assertEqual(resp.status_code, 200) # (3) response data self.assertDictEqual( resp.json, { 'extension11': { 'classNum': extension_apply_11.class_, 'seatNum': extension_apply_11.seat }, 'extension12': { 'classNum': extension_apply_12.class_, 'seatNum': extension_apply_12.seat }, 'goingout': { 'sat': goingout_apply.on_saturday, 'sun': goingout_apply.on_sunday }, 'stay': stay_apply.value })
def post(self): """ 11시 연장신청 """ student = g.user now = datetime.now().time() if not current_app.testing and not APPLY_START < now < APPLY_END_11: # Not testing, can't apply return Response('', 204) class_ = int(request.form['class_num']) seat = int(request.form['seat_num']) ExtensionApply11Model.objects(student=student).delete() if ExtensionApply11Model.objects(class_=class_, seat=seat): return Response('', 204) ExtensionApply11Model(student=student, class_=class_, seat=seat, apply_date=datetime.now()).save() return Response('', 201)