Skip to content

Commit

Permalink
Add booking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geuben committed Apr 14, 2020
1 parent a9e5e80 commit e150069
Show file tree
Hide file tree
Showing 7 changed files with 945 additions and 5 deletions.
11 changes: 9 additions & 2 deletions livestyled/models/booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ def __init__(
id,
type,
device_id,
user_id,
event_id,
created_at,
updated_at,
action,
user_id=None,
):
self._id = id
self.type = type
self._device = Device.placeholder(id=device_id)
self._user = User.placeholder(id=user_id)
if user_id:
self._user = User.placeholder(id=user_id)
else:
self._user = None
self._event = Event.placeholder(id=event_id)
self.created_at = created_at
self.updated_at = updated_at
Expand Down Expand Up @@ -50,6 +53,10 @@ def create_new(
booking._event = event
return booking

@property
def id(self):
return self._id

@property
def device_id(self):
return self._device.id
Expand Down
5 changes: 3 additions & 2 deletions livestyled/schemas/booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Meta:
device_id = RelatedResourceLinkField(schema=DeviceSchema, data_key='device')
user_id = RelatedResourceLinkField(schema=UserSchema, data_key='user')
event_id = RelatedResourceLinkField(schema=EventSchema, data_key='event')
created_at = fields.String(data_key='createdAt')
updated_at = fields.String(data_key='updatedAt')
updated_at = fields.AwareDateTime(data_key='updatedAt', allow_none=True)
created_at = fields.AwareDateTime(data_key='createdAt', allow_none=True)
action = fields.String()
type = fields.String()
Loading

0 comments on commit e150069

Please sign in to comment.