liniting, black, mypy fixes
This commit is contained in:
@ -38,9 +38,7 @@ class Artist(ormar.Model):
|
||||
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
|
||||
)
|
||||
children = ormar.ManyToMany(Child, through=ArtistChildren)
|
||||
|
||||
|
||||
class Album(ormar.Model):
|
||||
|
||||
@ -53,9 +53,7 @@ class Item(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
categories = ormar.ManyToMany(
|
||||
Category, through=ItemsXCategories
|
||||
)
|
||||
categories = ormar.ManyToMany(Category, through=ItemsXCategories)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -239,8 +239,8 @@ async def test_fk_filter():
|
||||
|
||||
tracks = (
|
||||
await Track.objects.select_related("album")
|
||||
.filter(album__name="Fantasies")
|
||||
.all()
|
||||
.filter(album__name="Fantasies")
|
||||
.all()
|
||||
)
|
||||
assert len(tracks) == 3
|
||||
for track in tracks:
|
||||
@ -248,8 +248,8 @@ async def test_fk_filter():
|
||||
|
||||
tracks = (
|
||||
await Track.objects.select_related("album")
|
||||
.filter(album__name__icontains="fan")
|
||||
.all()
|
||||
.filter(album__name__icontains="fan")
|
||||
.all()
|
||||
)
|
||||
assert len(tracks) == 3
|
||||
for track in tracks:
|
||||
@ -294,8 +294,8 @@ async def test_multiple_fk():
|
||||
|
||||
members = (
|
||||
await Member.objects.select_related("team__org")
|
||||
.filter(team__org__ident="ACME Ltd")
|
||||
.all()
|
||||
.filter(team__org__ident="ACME Ltd")
|
||||
.all()
|
||||
)
|
||||
assert len(members) == 4
|
||||
for member in members:
|
||||
@ -327,8 +327,8 @@ async def test_pk_filter():
|
||||
|
||||
tracks = (
|
||||
await Track.objects.select_related("album")
|
||||
.filter(position=2, album__name="Test")
|
||||
.all()
|
||||
.filter(position=2, album__name="Test")
|
||||
.all()
|
||||
)
|
||||
assert len(tracks) == 1
|
||||
|
||||
|
||||
@ -49,10 +49,8 @@ class Post(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
title = ormar.String(max_length=200)
|
||||
categories = ormar.ManyToMany(
|
||||
Category, through=PostCategory
|
||||
)
|
||||
author= ormar.ForeignKey(Author)
|
||||
categories = ormar.ManyToMany(Category, through=PostCategory)
|
||||
author = ormar.ForeignKey(Author)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -139,6 +139,7 @@ def test_sqlalchemy_table_is_created(example):
|
||||
@typing.no_type_check
|
||||
def test_no_pk_in_model_definition(): # type: ignore
|
||||
with pytest.raises(ModelDefinitionError): # type: ignore
|
||||
|
||||
class ExampleModel2(Model): # type: ignore
|
||||
class Meta:
|
||||
tablename = "example2"
|
||||
@ -150,6 +151,7 @@ def test_no_pk_in_model_definition(): # type: ignore
|
||||
@typing.no_type_check
|
||||
def test_two_pks_in_model_definition():
|
||||
with pytest.raises(ModelDefinitionError):
|
||||
|
||||
@typing.no_type_check
|
||||
class ExampleModel2(Model):
|
||||
class Meta:
|
||||
@ -163,6 +165,7 @@ def test_two_pks_in_model_definition():
|
||||
@typing.no_type_check
|
||||
def test_setting_pk_column_as_pydantic_only_in_model_definition():
|
||||
with pytest.raises(ModelDefinitionError):
|
||||
|
||||
class ExampleModel2(Model):
|
||||
class Meta:
|
||||
tablename = "example4"
|
||||
@ -174,6 +177,7 @@ def test_setting_pk_column_as_pydantic_only_in_model_definition():
|
||||
@typing.no_type_check
|
||||
def test_decimal_error_in_model_definition():
|
||||
with pytest.raises(ModelDefinitionError):
|
||||
|
||||
class ExampleModel2(Model):
|
||||
class Meta:
|
||||
tablename = "example5"
|
||||
@ -185,6 +189,7 @@ def test_decimal_error_in_model_definition():
|
||||
@typing.no_type_check
|
||||
def test_string_error_in_model_definition():
|
||||
with pytest.raises(ModelDefinitionError):
|
||||
|
||||
class ExampleModel2(Model):
|
||||
class Meta:
|
||||
tablename = "example6"
|
||||
|
||||
@ -23,7 +23,7 @@ class JsonSample(ormar.Model):
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
test_json= ormar.JSON(nullable=True)
|
||||
test_json = ormar.JSON(nullable=True)
|
||||
|
||||
|
||||
class UUIDSample(ormar.Model):
|
||||
@ -32,7 +32,7 @@ class UUIDSample(ormar.Model):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id= ormar.UUID(primary_key=True, default=uuid.uuid4)
|
||||
id = ormar.UUID(primary_key=True, default=uuid.uuid4)
|
||||
test_text = ormar.Text()
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ class Product(ormar.Model):
|
||||
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)
|
||||
in_stock = ormar.Boolean(default=False)
|
||||
last_delivery = ormar.Date(default=datetime.now)
|
||||
|
||||
|
||||
country_name_choices = ("Canada", "Algeria", "United States")
|
||||
@ -71,10 +71,8 @@ class Country(ormar.Model):
|
||||
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)
|
||||
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(
|
||||
minimum=0, maximum=1000, choices=country_country_code_choices, default=1
|
||||
)
|
||||
|
||||
@ -40,7 +40,7 @@ class Category(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
department= ormar.ForeignKey(Department, nullable=False)
|
||||
department = ormar.ForeignKey(Department, nullable=False)
|
||||
|
||||
|
||||
class Student(ormar.Model):
|
||||
@ -51,8 +51,8 @@ class Student(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass= ormar.ForeignKey(SchoolClass)
|
||||
category= ormar.ForeignKey(Category, nullable=True)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
class Teacher(ormar.Model):
|
||||
@ -63,8 +63,8 @@ class Teacher(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass= ormar.ForeignKey(SchoolClass)
|
||||
category= ormar.ForeignKey(Category, nullable=True)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -29,7 +29,7 @@ class Track(ormar.Model):
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
album= ormar.ForeignKey(Album)
|
||||
album = ormar.ForeignKey(Album)
|
||||
title = ormar.String(max_length=100)
|
||||
position = ormar.Integer()
|
||||
|
||||
@ -41,7 +41,7 @@ class Cover(ormar.Model):
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
album= ormar.ForeignKey(Album, related_name="cover_pictures")
|
||||
album = ormar.ForeignKey(Album, related_name="cover_pictures")
|
||||
title = ormar.String(max_length=100)
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ class Team(ormar.Model):
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
org= ormar.ForeignKey(Organisation)
|
||||
org = ormar.ForeignKey(Organisation)
|
||||
name = ormar.String(max_length=100)
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ class Member(ormar.Model):
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
team= ormar.ForeignKey(Team)
|
||||
team = ormar.ForeignKey(Team)
|
||||
email = ormar.String(max_length=100)
|
||||
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class ToDo(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
text = ormar.String(max_length=500)
|
||||
completed= ormar.Boolean(default=False)
|
||||
completed = ormar.Boolean(default=False)
|
||||
|
||||
|
||||
class Category(ormar.Model):
|
||||
@ -57,7 +57,7 @@ class Note(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
text = ormar.String(max_length=500)
|
||||
category= ormar.ForeignKey(Category)
|
||||
category = ormar.ForeignKey(Category)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="module")
|
||||
|
||||
@ -30,7 +30,7 @@ class SchoolClass(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
department= ormar.ForeignKey(Department, nullable=False)
|
||||
department = ormar.ForeignKey(Department, nullable=False)
|
||||
|
||||
|
||||
class Category(ormar.Model):
|
||||
@ -51,8 +51,8 @@ class Student(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass= ormar.ForeignKey(SchoolClass)
|
||||
category= ormar.ForeignKey(Category, nullable=True)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
class Teacher(ormar.Model):
|
||||
@ -63,8 +63,8 @@ class Teacher(ormar.Model):
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
name = ormar.String(max_length=100)
|
||||
schoolclass= ormar.ForeignKey(SchoolClass)
|
||||
category= ormar.ForeignKey(Category, nullable=True)
|
||||
schoolclass = ormar.ForeignKey(SchoolClass)
|
||||
category = ormar.ForeignKey(Category, nullable=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
@ -30,7 +30,7 @@ class Car(ormar.Model):
|
||||
database = database
|
||||
|
||||
id = ormar.Integer(primary_key=True)
|
||||
manufacturer= ormar.ForeignKey(Company)
|
||||
manufacturer = ormar.ForeignKey(Company)
|
||||
name = ormar.String(max_length=100)
|
||||
year = ormar.Integer(nullable=True)
|
||||
gearbox_type = ormar.String(max_length=20, nullable=True)
|
||||
|
||||
@ -24,7 +24,7 @@ class Product(ormar.Model):
|
||||
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())
|
||||
created = ormar.DateTime(server_default=func.now())
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
||||
Reference in New Issue
Block a user