Tests
- Improved directory structure - Added functional and unit tests
This commit is contained in:
111
api/app/schema.py
Normal file
111
api/app/schema.py
Normal file
@@ -0,0 +1,111 @@
|
||||
from apiflask import Schema
|
||||
from apiflask.fields import Integer, String, Boolean, Field, Float
|
||||
from marshmallow import validate
|
||||
from marshmallow.fields import Email
|
||||
|
||||
|
||||
class BaseResponseSchema(Schema):
|
||||
text = String()
|
||||
status = Integer()
|
||||
data = Field()
|
||||
|
||||
|
||||
class UsersSchema(Schema):
|
||||
admin = Boolean()
|
||||
password = String()
|
||||
username = String()
|
||||
telegram_user_id = String()
|
||||
email = Email()
|
||||
|
||||
|
||||
class AdminDataSchema(Schema):
|
||||
email = Email()
|
||||
admin = Boolean()
|
||||
|
||||
|
||||
class TokenSchema(Schema):
|
||||
token = String()
|
||||
|
||||
|
||||
class LoginDataSchema(Schema):
|
||||
email = Email()
|
||||
password = String()
|
||||
|
||||
|
||||
class RegisterDataSchema(Schema):
|
||||
email = Email()
|
||||
username = String()
|
||||
password = String()
|
||||
|
||||
|
||||
class UpdateUserDataSchema(Schema):
|
||||
username = String(required=False)
|
||||
password = String(required=False)
|
||||
|
||||
|
||||
class DeleteUserSchema(Schema):
|
||||
email = Email()
|
||||
|
||||
|
||||
class ChangePasswordSchema(Schema):
|
||||
old_password = String()
|
||||
new_password = String()
|
||||
|
||||
|
||||
class ChangeUsernameSchema(Schema):
|
||||
new_username = String()
|
||||
|
||||
|
||||
class KeywordSchema(Schema):
|
||||
keyword = String()
|
||||
|
||||
|
||||
class SymbolSchema(Schema):
|
||||
symbol = String()
|
||||
|
||||
|
||||
class TransactionSchema(Schema):
|
||||
symbol = String()
|
||||
time = String(validate=validate.Regexp(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z"))
|
||||
count = Integer()
|
||||
price = Float()
|
||||
|
||||
|
||||
class TelegramIdSchema(Schema):
|
||||
telegram_user_id = String()
|
||||
|
||||
|
||||
class DeleteSuccessfulSchema(Schema):
|
||||
pass
|
||||
|
||||
|
||||
class KeywordResponseSchema(Schema):
|
||||
keyword = String()
|
||||
s_id = Integer()
|
||||
email = Email()
|
||||
|
||||
|
||||
class SymbolResponseSchema(Schema):
|
||||
symbol = String()
|
||||
s_id = Integer()
|
||||
email = Email()
|
||||
|
||||
|
||||
class PortfolioShareResponseSchema(Schema):
|
||||
count = Integer()
|
||||
last_transaction = String()
|
||||
|
||||
|
||||
class TransactionResponseSchema(Schema):
|
||||
email = Email()
|
||||
symbol = String()
|
||||
time = String()
|
||||
count = Integer()
|
||||
price = Float()
|
||||
|
||||
|
||||
class PortfolioResponseSchema(Schema):
|
||||
symbol = String()
|
||||
last_transaction = String()
|
||||
count = Integer()
|
||||
# price = Float()
|
Reference in New Issue
Block a user