Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_datetime_type():
class SchemaExample(schemas.Model):
my_datetime = schemas.DateTimeType()
test_date = datetime(2016, 1, 1, tzinfo=pytz.UTC)
assert SchemaExample({"my_datetime": "2016-01-01T00:00:00+00:00"}).my_datetime == test_date
assert SchemaExample({"my_datetime": "2016-01-01T00:00:00+0000"}).my_datetime == test_date
assert SchemaExample({"my_datetime": "2016-01-01T00:00:00Z"}).my_datetime == test_date
assert SchemaExample({"my_datetime": test_date}).my_datetime == test_date
# `local_rank`, `aviation_rank`, and `phq_attendance` are paid features.
# They will only show up in your response body if you
# have subscribed to them.
local_rank = IntType()
aviation_rank = IntType()
phq_attendance = IntType()
entities = ListType(ModelType(Entities))
location = GeoJSONPointType()
place_hierarchies = ListType(ListType(StringType()))
scope = StringType()
relevance = FloatType()
state = StringType()
first_seen = DateTimeType()
updated = DateTimeType()
deleted_reason = StringType()
duplicate_of_id = StringType()
class EventResultSet(ResultSet):
overflow = BooleanType()
results = ResultType(Event)
class CountResultSet(Model):
count = IntType()
top_rank = FloatType()
rank_levels = DictType(IntType)
serialize_when_none = False
origin = StringType(regex='(-?\d+(\.\d+)?),(-?\d+(\.\d+)?)', required=True)
offset = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
scale = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
decay = FloatType()
class DateTimeRange(Model):
class Options:
serialize_when_none = False
gt = DateTimeType()
gte = DateTimeType()
lt = DateTimeType()
lte = DateTimeType()
tz = StringType(choices=pytz.all_timezones)
class FloatRange(Model):
class Options:
serialize_when_none = False
gt = FloatType()
gte = FloatType()
lt = FloatType()
lte = FloatType()
class IntRange(Model):
class Options(Signal.Options):
pass
class SignalResultSet(ResultSet):
results = ResultType(SavedSignal)
class DataPoint(Model):
uid = StringType(required=True)
date = DateTimeType(required=True)
latitude = FloatType(min_value=-90, max_value=90, required=True)
longitude = FloatType(min_value=-180, max_value=180, required=True)
initiated = DateTimeType()
completed = DateTimeType()
# @todo: Support custom dimensions from signal
class SignalDataPoints(Model):
id = StringType(required=True)
data_points = ListType(ModelType(DataPoint), required=True)
chunk_size = IntType(default=1000, max_value=5000, required=True)
class DateDimension(Model):
type = StringType()
count = IntType()
min = DateTimeType()
pass
class SignalResultSet(ResultSet):
results = ResultType(SavedSignal)
class DataPoint(Model):
uid = StringType(required=True)
date = DateTimeType(required=True)
latitude = FloatType(min_value=-90, max_value=90, required=True)
longitude = FloatType(min_value=-180, max_value=180, required=True)
initiated = DateTimeType()
completed = DateTimeType()
# @todo: Support custom dimensions from signal
class SignalDataPoints(Model):
id = StringType(required=True)
data_points = ListType(ModelType(DataPoint), required=True)
chunk_size = IntType(default=1000, max_value=5000, required=True)
class DateDimension(Model):
type = StringType()
count = IntType()
min = DateTimeType()
max = DateTimeType()
from predicthq.endpoints.schemas import Model, StringType, DateTimeType, ModelType
class Industry(Model):
id = StringType()
name = StringType()
class Account(Model):
id = StringType()
name = StringType()
description = StringType()
industry = ModelType(Industry)
created_at = DateTimeType()
updated_at = DateTimeType()
origin = StringType(regex='(-?\d+(\.\d+)?),(-?\d+(\.\d+)?)', required=True)
offset = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
scale = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
decay = FloatType()
class DateTimeRange(Model):
class Options:
serialize_when_none = False
gt = DateTimeType()
gte = DateTimeType()
lt = DateTimeType()
lte = DateTimeType()
tz = StringType(choices=pytz.all_timezones)
class FloatRange(Model):
class Options:
serialize_when_none = False
gt = FloatType()
gte = FloatType()
lt = FloatType()
lte = FloatType()
class IntRange(Model):
class Options:
serialize_when_none = False
origin = StringType(regex='(-?\d+(\.\d+)?),(-?\d+(\.\d+)?)', required=True)
offset = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
scale = StringType(regex='\d+(\.\d+)?(cm|m|km|in|ft|mi)')
decay = FloatType()
class DateTimeRange(Model):
class Options:
serialize_when_none = False
gt = DateTimeType()
gte = DateTimeType()
lt = DateTimeType()
lte = DateTimeType()
tz = StringType(choices=pytz.all_timezones)
class FloatRange(Model):
class Options:
serialize_when_none = False
gt = FloatType()
gte = FloatType()
lt = FloatType()
lte = FloatType()
class Options:
serialize_when_none = False
scope = ListType(StringType)
exact = ListType(StringType)
class Signal(Model):
class Options:
serialize_when_none = False
id = StringType(required=True)
analysis_from = DateTimeType()
analysis_to = DateTimeType()
analysis_tz = StringType(choices=pytz.all_timezones)
significance = FloatType(min_value=0, max_value=100)
metric = StringType(choices=('demand', 'lead', 'span'))
explain = DateType()
class DateAround(Model):
class Options:
serialize_when_none = False
origin = DateType(required=True)
offset = StringType(regex='\d+d')
scale = StringType(regex='\d+d')
decay = FloatType()