Skip to content

Commit

Permalink
Add: begintime and endtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyo-k committed Feb 7, 2020
1 parent 3073ff3 commit 977df5b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<Classroom %r%r>".format(self.grade, self.get_classroom_name)
Expand Down
2 changes: 2 additions & 0 deletions api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions test/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 977df5b

Please sign in to comment.