restore typing in tests and docs, remove unused metaclass code
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
from typing import Optional, Union, List
|
||||
|
||||
import databases
|
||||
import pytest
|
||||
import sqlalchemy
|
||||
@ -15,10 +17,10 @@ class Child(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(name="child_id", primary_key=True)
|
||||
first_name = ormar.String(name="fname", max_length=100)
|
||||
last_name = ormar.String(name="lname", max_length=100)
|
||||
born_year = ormar.Integer(name="year_born", nullable=True)
|
||||
id: int = ormar.Integer(name="child_id", primary_key=True)
|
||||
first_name: str = ormar.String(name="fname", max_length=100)
|
||||
last_name: str = ormar.String(name="lname", max_length=100)
|
||||
born_year: int = ormar.Integer(name="year_born", nullable=True)
|
||||
|
||||
|
||||
class ArtistChildren(ormar.Model):
|
||||
@ -34,11 +36,11 @@ class Artist(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(name="artist_id", primary_key=True)
|
||||
first_name = ormar.String(name="fname", max_length=100)
|
||||
last_name = ormar.String(name="lname", max_length=100)
|
||||
born_year = ormar.Integer(name="year")
|
||||
children = ormar.ManyToMany(Child, through=ArtistChildren)
|
||||
id: int = ormar.Integer(name="artist_id", primary_key=True)
|
||||
first_name: str = ormar.String(name="fname", max_length=100)
|
||||
last_name: str = ormar.String(name="lname", max_length=100)
|
||||
born_year: int = ormar.Integer(name="year")
|
||||
children: Optional[Union[Child, List[Child]]] = ormar.ManyToMany(Child, through=ArtistChildren)
|
||||
|
||||
|
||||
class Album(ormar.Model):
|
||||
@ -47,9 +49,9 @@ class Album(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(name="album_id", primary_key=True)
|
||||
name = ormar.String(name="album_name", max_length=100)
|
||||
artist = ormar.ForeignKey(Artist, name="artist_id")
|
||||
id: int = ormar.Integer(name="album_id", primary_key=True)
|
||||
name: str = ormar.String(name="album_name", max_length=100)
|
||||
artist: Optional[Artist] = ormar.ForeignKey(Artist, name="artist_id")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -23,14 +23,14 @@ class Example(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=200, default="aaa")
|
||||
created = ormar.DateTime(default=datetime.datetime.now)
|
||||
created_day = ormar.Date(default=datetime.date.today)
|
||||
created_time = ormar.Time(default=time)
|
||||
description = ormar.Text(nullable=True)
|
||||
value = ormar.Float(nullable=True)
|
||||
data = ormar.JSON(default={})
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=200, default="aaa")
|
||||
created: datetime.datetime = ormar.DateTime(default=datetime.datetime.now)
|
||||
created_day: datetime.date = ormar.Date(default=datetime.date.today)
|
||||
created_time: datetime.time = ormar.Time(default=time)
|
||||
description: str = ormar.Text(nullable=True)
|
||||
value: float = ormar.Float(nullable=True)
|
||||
data: pydantic.Json = ormar.JSON(default={})
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
0
tests/test_docs/__init__.py
Normal file
0
tests/test_docs/__init__.py
Normal file
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Union, Optional
|
||||
|
||||
import databases
|
||||
import pytest
|
||||
@ -38,8 +38,8 @@ class Category(ormar.Model):
|
||||
class Meta(LocalMeta):
|
||||
tablename = "categories"
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class ItemsXCategories(ormar.Model):
|
||||
@ -51,8 +51,8 @@ class Item(ormar.Model):
|
||||
class Meta(LocalMeta):
|
||||
pass
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
categories = ormar.ManyToMany(Category, through=ItemsXCategories)
|
||||
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@ class Category(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Item(ormar.Model):
|
||||
@ -30,9 +30,9 @@ class Item(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
@app.post("/items/", response_model=Item)
|
||||
|
||||
@ -40,9 +40,9 @@ class Cover(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
album = ormar.ForeignKey(Album, related_name="cover_pictures")
|
||||
title = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
album: Optional[Album] = ormar.ForeignKey(Album, related_name="cover_pictures")
|
||||
title: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Organisation(ormar.Model):
|
||||
@ -51,8 +51,8 @@ class Organisation(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
ident = ormar.String(max_length=100, choices=["ACME Ltd", "Other ltd"])
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
ident: str = ormar.String(max_length=100, choices=["ACME Ltd", "Other ltd"])
|
||||
|
||||
|
||||
class Organization(object):
|
||||
@ -65,9 +65,9 @@ class Team(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
org = ormar.ForeignKey(Organisation)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
org: Optional[Organisation] = ormar.ForeignKey(Organisation)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Member(ormar.Model):
|
||||
@ -76,9 +76,9 @@ class Member(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
team = ormar.ForeignKey(Team)
|
||||
email = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
team: Optional[Team] = ormar.ForeignKey(Team)
|
||||
email: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -19,9 +19,9 @@ class Author(ormar.Model):
|
||||
database = database
|
||||
metadata = metadata
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
first_name = ormar.String(max_length=80)
|
||||
last_name = ormar.String(max_length=80)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
first_name: str = ormar.String(max_length=80)
|
||||
last_name: str = ormar.String(max_length=80)
|
||||
|
||||
|
||||
class Category(ormar.Model):
|
||||
@ -30,8 +30,8 @@ class Category(ormar.Model):
|
||||
database = database
|
||||
metadata = metadata
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=40)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=40)
|
||||
|
||||
|
||||
class PostCategory(ormar.Model):
|
||||
@ -47,10 +47,10 @@ class Post(ormar.Model):
|
||||
database = database
|
||||
metadata = metadata
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
title = ormar.String(max_length=200)
|
||||
categories = ormar.ManyToMany(Category, through=PostCategory)
|
||||
author = ormar.ForeignKey(Author)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
title: str = ormar.String(max_length=200)
|
||||
categories: Optional[Union[Category, List[Category]]] = ormar.ManyToMany(Category, through=PostCategory)
|
||||
author: Optional[Author] = ormar.ForeignKey(Author)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -21,16 +21,16 @@ class ExampleModel(Model):
|
||||
tablename = "example"
|
||||
metadata = metadata
|
||||
|
||||
test = ormar.Integer(primary_key=True)
|
||||
test_string = ormar.String(max_length=250)
|
||||
test_text = ormar.Text(default="")
|
||||
test_bool = ormar.Boolean(nullable=False)
|
||||
test: int = ormar.Integer(primary_key=True)
|
||||
test_string: str = ormar.String(max_length=250)
|
||||
test_text: str = ormar.Text(default="")
|
||||
test_bool: bool = ormar.Boolean(nullable=False)
|
||||
test_float: ormar.Float() = None # type: ignore
|
||||
test_datetime = ormar.DateTime(default=datetime.datetime.now)
|
||||
test_date = ormar.Date(default=datetime.date.today)
|
||||
test_time = ormar.Time(default=datetime.time)
|
||||
test_json = ormar.JSON(default={})
|
||||
test_bigint = ormar.BigInteger(default=0)
|
||||
test_bigint: int = ormar.BigInteger(default=0)
|
||||
test_decimal = ormar.Decimal(scale=2, precision=10)
|
||||
test_decimal2 = ormar.Decimal(max_digits=10, decimal_places=2)
|
||||
|
||||
@ -53,8 +53,8 @@ class ExampleModel2(Model):
|
||||
tablename = "examples"
|
||||
metadata = metadata
|
||||
|
||||
test = ormar.Integer(primary_key=True)
|
||||
test_string = ormar.String(max_length=250)
|
||||
test: int = ormar.Integer(primary_key=True)
|
||||
test_string: str = ormar.String(max_length=250)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@ -145,7 +145,7 @@ def test_no_pk_in_model_definition(): # type: ignore
|
||||
tablename = "example2"
|
||||
metadata = metadata
|
||||
|
||||
test_string = ormar.String(max_length=250) # type: ignore
|
||||
test_string: str = ormar.String(max_length=250) # type: ignore
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
@ -158,8 +158,8 @@ def test_two_pks_in_model_definition():
|
||||
tablename = "example3"
|
||||
metadata = metadata
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
test_string = ormar.String(max_length=250, primary_key=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
test_string: str = ormar.String(max_length=250, primary_key=True)
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
@ -171,7 +171,7 @@ def test_setting_pk_column_as_pydantic_only_in_model_definition():
|
||||
tablename = "example4"
|
||||
metadata = metadata
|
||||
|
||||
test = ormar.Integer(primary_key=True, pydantic_only=True)
|
||||
test: int = ormar.Integer(primary_key=True, pydantic_only=True)
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
@ -183,7 +183,7 @@ def test_decimal_error_in_model_definition():
|
||||
tablename = "example5"
|
||||
metadata = metadata
|
||||
|
||||
test = ormar.Decimal(primary_key=True)
|
||||
test: decimal.Decimal = ormar.Decimal(primary_key=True)
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
@ -195,7 +195,7 @@ def test_string_error_in_model_definition():
|
||||
tablename = "example6"
|
||||
metadata = metadata
|
||||
|
||||
test = ormar.String(primary_key=True)
|
||||
test: str = ormar.String(primary_key=True)
|
||||
|
||||
|
||||
@typing.no_type_check
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from typing import List
|
||||
|
||||
import databases
|
||||
@ -22,7 +22,7 @@ class JsonSample(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
test_json = ormar.JSON(nullable=True)
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ class UUIDSample(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.UUID(primary_key=True, default=uuid.uuid4)
|
||||
test_text = ormar.Text()
|
||||
id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4)
|
||||
test_text: str = ormar.Text()
|
||||
|
||||
|
||||
class User(ormar.Model):
|
||||
@ -42,8 +42,8 @@ class User(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100, default="")
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100, default="")
|
||||
|
||||
|
||||
class Product(ormar.Model):
|
||||
@ -52,11 +52,11 @@ class Product(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
rating = ormar.Integer(minimum=1, maximum=5)
|
||||
in_stock = ormar.Boolean(default=False)
|
||||
last_delivery = ormar.Date(default=datetime.now)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
rating: int = ormar.Integer(minimum=1, maximum=5)
|
||||
in_stock: bool = ormar.Boolean(default=False)
|
||||
last_delivery: datetime.date = ormar.Date(default=datetime.datetime.now)
|
||||
|
||||
|
||||
country_name_choices = ("Canada", "Algeria", "United States")
|
||||
@ -70,10 +70,10 @@ class Country(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=9, choices=country_name_choices, default="Canada",)
|
||||
taxed = ormar.Boolean(choices=country_taxed_choices, default=True)
|
||||
country_code = ormar.Integer(
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=9, choices=country_name_choices, default="Canada",)
|
||||
taxed: bool = ormar.Boolean(choices=country_taxed_choices, default=True)
|
||||
country_code: int = ormar.Integer(
|
||||
minimum=0, maximum=1000, choices=country_country_code_choices, default=1
|
||||
)
|
||||
|
||||
@ -213,7 +213,7 @@ async def test_model_filter():
|
||||
assert product.pk is not None
|
||||
assert product.name == "T-Shirt"
|
||||
assert product.rating == 5
|
||||
assert product.last_delivery == datetime.now().date()
|
||||
assert product.last_delivery == datetime.datetime.now().date()
|
||||
|
||||
products = await Product.objects.all(rating__gte=2, in_stock=True)
|
||||
assert len(products) == 2
|
||||
|
||||
@ -35,8 +35,8 @@ class Category(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Item(ormar.Model):
|
||||
@ -45,9 +45,9 @@ class Item(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -18,8 +18,8 @@ class Department(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True, autoincrement=False)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True, autoincrement=False)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class SchoolClass(ormar.Model):
|
||||
@ -28,8 +28,8 @@ class SchoolClass(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Category(ormar.Model):
|
||||
@ -38,9 +38,9 @@ class Category(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
department = ormar.ForeignKey(Department, nullable=False)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
department: Optional[Department] = ormar.ForeignKey(Department, nullable=False)
|
||||
|
||||
|
||||
class Student(ormar.Model):
|
||||
@ -49,10 +49,10 @@ class Student(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
schoolclass: Optional[SchoolClass] = ormar.ForeignKey(SchoolClass)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
class Teacher(ormar.Model):
|
||||
@ -61,10 +61,10 @@ class Teacher(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
schoolclass: Optional[SchoolClass] = ormar.ForeignKey(SchoolClass)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -18,8 +18,8 @@ class Album(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Track(ormar.Model):
|
||||
@ -28,10 +28,10 @@ class Track(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
album = ormar.ForeignKey(Album)
|
||||
title = ormar.String(max_length=100)
|
||||
position = ormar.Integer()
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
album: Optional[Album] = ormar.ForeignKey(Album)
|
||||
title: str = ormar.String(max_length=100)
|
||||
position: int = ormar.Integer()
|
||||
|
||||
|
||||
class Cover(ormar.Model):
|
||||
@ -40,9 +40,9 @@ class Cover(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
album = ormar.ForeignKey(Album, related_name="cover_pictures")
|
||||
title = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
album: Optional[Album] = ormar.ForeignKey(Album, related_name="cover_pictures")
|
||||
title: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Organisation(ormar.Model):
|
||||
@ -51,8 +51,8 @@ class Organisation(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
ident = ormar.String(max_length=100, choices=["ACME Ltd", "Other ltd"])
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
ident: str = ormar.String(max_length=100, choices=["ACME Ltd", "Other ltd"])
|
||||
|
||||
|
||||
class Team(ormar.Model):
|
||||
@ -61,9 +61,9 @@ class Team(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
org = ormar.ForeignKey(Organisation)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
org: Optional[Organisation] = ormar.ForeignKey(Organisation)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Member(ormar.Model):
|
||||
@ -72,9 +72,9 @@ class Member(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
team = ormar.ForeignKey(Team)
|
||||
email = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
team: Optional[Team] = ormar.ForeignKey(Team)
|
||||
email: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -21,8 +21,8 @@ class Model(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.String(primary_key=True, default=key, max_length=8)
|
||||
name = ormar.String(max_length=32)
|
||||
id: str = ormar.String(primary_key=True, default=key, max_length=8)
|
||||
name: str = ormar.String(max_length=32)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="function")
|
||||
|
||||
@ -18,10 +18,10 @@ class Book(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
title = ormar.String(max_length=200)
|
||||
author = ormar.String(max_length=100)
|
||||
genre = ormar.String(
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
title: str = ormar.String(max_length=200)
|
||||
author: str = ormar.String(max_length=100)
|
||||
genre: str = ormar.String(
|
||||
max_length=100,
|
||||
default="Fiction",
|
||||
choices=["Fiction", "Adventure", "Historic", "Fantasy"],
|
||||
@ -34,9 +34,9 @@ class ToDo(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
text = ormar.String(max_length=500)
|
||||
completed = ormar.Boolean(default=False)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
text: str = ormar.String(max_length=500)
|
||||
completed: bool = ormar.Boolean(default=False)
|
||||
|
||||
|
||||
class Category(ormar.Model):
|
||||
@ -45,8 +45,8 @@ class Category(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=500)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=500)
|
||||
|
||||
|
||||
class Note(ormar.Model):
|
||||
@ -55,9 +55,9 @@ class Note(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
text = ormar.String(max_length=500)
|
||||
category = ormar.ForeignKey(Category)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
text: str = ormar.String(max_length=500)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -18,8 +18,8 @@ class Department(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True, autoincrement=False)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True, autoincrement=False)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class SchoolClass(ormar.Model):
|
||||
@ -28,9 +28,9 @@ class SchoolClass(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
department = ormar.ForeignKey(Department, nullable=False)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
department: Optional[Department] = ormar.ForeignKey(Department, nullable=False)
|
||||
|
||||
|
||||
class Category(ormar.Model):
|
||||
@ -39,8 +39,8 @@ class Category(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
|
||||
|
||||
class Student(ormar.Model):
|
||||
@ -49,10 +49,10 @@ class Student(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
schoolclass: Optional[SchoolClass] = ormar.ForeignKey(SchoolClass)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
class Teacher(ormar.Model):
|
||||
@ -61,10 +61,10 @@ class Teacher(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
schoolclass: Optional[SchoolClass] = ormar.ForeignKey(SchoolClass)
|
||||
category: Optional[Category] = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -18,9 +18,9 @@ class Company(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100, nullable=False)
|
||||
founded = ormar.Integer(nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100, nullable=False)
|
||||
founded: int = ormar.Integer(nullable=True)
|
||||
|
||||
|
||||
class Car(ormar.Model):
|
||||
@ -29,13 +29,13 @@ class Car(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
manufacturer = ormar.ForeignKey(Company)
|
||||
name = ormar.String(max_length=100)
|
||||
year = ormar.Integer(nullable=True)
|
||||
gearbox_type = ormar.String(max_length=20, nullable=True)
|
||||
gears = ormar.Integer(nullable=True)
|
||||
aircon_type = ormar.String(max_length=20, nullable=True)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
manufacturer: Optional[Company] = ormar.ForeignKey(Company)
|
||||
name: str = ormar.String(max_length=100)
|
||||
year: int = ormar.Integer(nullable=True)
|
||||
gearbox_type: str = ormar.String(max_length=20, nullable=True)
|
||||
gears: int = ormar.Integer(nullable=True)
|
||||
aircon_type: str = ormar.String(max_length=20, nullable=True)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -20,11 +20,11 @@ class Product(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
company = ormar.String(max_length=200, server_default="Acme")
|
||||
sort_order = ormar.Integer(server_default=text("10"))
|
||||
created = ormar.DateTime(server_default=func.now())
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
company: str = ormar.String(max_length=200, server_default="Acme")
|
||||
sort_order: int = ormar.Integer(server_default=text("10"))
|
||||
created: datetime = ormar.DateTime(server_default=func.now())
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -21,9 +21,9 @@ class Product(ormar.Model):
|
||||
database = database
|
||||
constraints = [ormar.UniqueColumns("name", "company")]
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
company = ormar.String(max_length=200)
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
company: str = ormar.String(max_length=200)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
Reference in New Issue
Block a user