class Account(models.DeclarativeBase): id = fields.UUIDField() email = fields.StringField() first_name = fields.StringField() last_name = fields.StringField() code = fields.NestedField(Code) created_date = fields.DateTimeField() updated_date = fields.DateTimeField()
class Message(models.DeclarativeBase): conversation = fields.NestedField(Conversation) platform = fields.NestedField(Platform) sender = fields.StringField() receiver = fields.StringField() identifier = fields.StringField() intent = fields.StringField() content = fields.StringField() raw = fields.StringField() extra = fields.JSONField() timestamp = fields.DateTimeField()
def test_date_time_fields_ignore_missing_values(self): field = fields.DateTimeField() assert field.parse("") == "" assert field.parse(None) is None assert field.encode("") == "" assert field.encode(None) is None field = fields.DateField() assert field.parse("") == "" assert field.parse(None) is None assert field.encode("") == "" assert field.encode(None) is None field = fields.TimeField() assert field.parse("") == "" assert field.parse(None) is None assert field.encode("") == "" assert field.encode(None) is None
def test_date_time_field_recognizes_string_values(self): field = fields.DateTimeField() response = field.parse("2010-01-01T13:23:57Z").replace(tzinfo=None) assert datetime.datetime(2010, 1, 1, 13, 23, 57, ) == response
def test_date_time_field_creates_proper_format(self): field = fields.DateTimeField() date_value = datetime.datetime(2010, 1, 1, 13, 23, 57) assert "2010-01-01T13:23:57Z" == field.encode(date_value)
class Conversation(models.DeclarativeBase): id = fields.UUIDField() platform = fields.NestedField(Platform) account = fields.NestedField(Account) created_date = fields.DateTimeField() updated_date = fields.DateTimeField()
class Example(models.DeclarativeBase): timestamp = fields.DateTimeField()