From 977df5bc93c156e51bc46ef0f4d33e8f32b7c09f Mon Sep 17 00:00:00 2001 From: kuwa Date: Fri, 7 Feb 2020 17:48:02 +0900 Subject: [PATCH] Add: begintime and endtime --- api/models.py | 3 +++ api/schemas.py | 2 ++ test/test_schema.py | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/api/models.py b/api/models.py index de83faa..996e52c 100644 --- a/api/models.py +++ b/api/models.py @@ -48,6 +48,9 @@ class Classroom(db.Model): grade = db.Column(db.Integer) index = db.Column(db.Integer) title = db.Column(db.String(300)) + begin_time = db.Column(db.Time) + end_time = db.Column(db.Time) + def __repr__(self): return "".format(self.grade, self.get_classroom_name) diff --git a/api/schemas.py b/api/schemas.py index e858f2e..5248f2d 100644 --- a/api/schemas.py +++ b/api/schemas.py @@ -66,6 +66,8 @@ class ClassroomSchema(Schema): index = fields.Int() title = fields.Method("classroom_title", dump_only=True) name = fields.Method("classroom_name", dump_only=True) + begin_time = fields.Time() + end_time = fields.Time() def classroom_name(self, classroom): return classroom.get_classroom_name() diff --git a/test/test_schema.py b/test/test_schema.py index 5d73c75..56887cb 100644 --- a/test/test_schema.py +++ b/test/test_schema.py @@ -35,3 +35,12 @@ def test_application_not_member(client): dumpdata = application_schema.dump(member_app)[0] assert not dumpdata['is_member'] + + +def test_classroom_time(client): + with client.application.app_context(): + target_classroom = Classroom.query.first() + + dumpdata = classroom_schema.dump(target_classroom) + assert 'begin_time' in dumpdata + assert 'end_time' in dumpdata