resolve merge conflicts
This commit is contained in:
@ -25,7 +25,7 @@ class BaseMeta(ormar.ModelMeta):
|
||||
|
||||
|
||||
default_fernet = dict(
|
||||
encrypt_secret="asd123", encrypt_backend=ormar.EncryptBackends.FERNET,
|
||||
encrypt_secret="asd123", encrypt_backend=ormar.EncryptBackends.FERNET
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ class Project(orm.Model):
|
||||
type: str = orm.String(max_length=10, default="cs")
|
||||
target_branch_name: str = orm.String(max_length=100, default="master")
|
||||
header: str = orm.String(max_length=250, default="")
|
||||
jira_url: str = orm.String(max_length=500,)
|
||||
jira_url: str = orm.String(max_length=500)
|
||||
changelog_file: str = orm.String(max_length=250, default="")
|
||||
version_file: str = orm.String(max_length=250, default="")
|
||||
|
||||
|
||||
@ -106,13 +106,7 @@ def compare_results_include(excludable):
|
||||
|
||||
|
||||
def test_excluding_fields_from_list():
|
||||
fields = [
|
||||
"gearbox_type",
|
||||
"gears",
|
||||
"aircon_type",
|
||||
"year",
|
||||
"manufacturer__founded",
|
||||
]
|
||||
fields = ["gearbox_type", "gears", "aircon_type", "year", "manufacturer__founded"]
|
||||
excludable = ExcludableItems()
|
||||
excludable.build(items=fields, model_cls=Car, is_exclude=True)
|
||||
compare_results(excludable)
|
||||
@ -174,7 +168,7 @@ def test_nested_includes_from_dict():
|
||||
fields = {
|
||||
"id": ...,
|
||||
"name": ...,
|
||||
"manufacturer": {"name": ..., "hq": {"name": ..., "nicks": {"name": ...}},},
|
||||
"manufacturer": {"name": ..., "hq": {"name": ..., "nicks": {"name": ...}}},
|
||||
}
|
||||
excludable = ExcludableItems()
|
||||
excludable.build(items=fields, model_cls=Car, is_exclude=False)
|
||||
@ -185,7 +179,7 @@ def test_nested_includes_from_dict_with_set():
|
||||
fields = {
|
||||
"id": ...,
|
||||
"name": ...,
|
||||
"manufacturer": {"name": ..., "hq": {"name": ..., "nicks": {"name"}},},
|
||||
"manufacturer": {"name": ..., "hq": {"name": ..., "nicks": {"name"}}},
|
||||
}
|
||||
excludable = ExcludableItems()
|
||||
excludable.build(items=fields, model_cls=Car, is_exclude=False)
|
||||
|
||||
@ -167,11 +167,7 @@ def test_excluding_fields_in_endpoints():
|
||||
assert created_user.pk is not None
|
||||
assert created_user.password is None
|
||||
|
||||
user2 = {
|
||||
"email": "test@domain.com",
|
||||
"first_name": "John",
|
||||
"last_name": "Doe",
|
||||
}
|
||||
user2 = {"email": "test@domain.com", "first_name": "John", "last_name": "Doe"}
|
||||
|
||||
response = client.post("/users/", json=user2)
|
||||
created_user = User(**response.json())
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import datetime
|
||||
import decimal
|
||||
import uuid
|
||||
from base64 import b64encode
|
||||
from enum import Enum
|
||||
|
||||
import databases
|
||||
@ -60,7 +59,7 @@ class Organisation(ormar.Model):
|
||||
random_decimal: decimal.Decimal = ormar.Decimal(
|
||||
scale=2, precision=4, choices=[decimal.Decimal(12.4), decimal.Decimal(58.2)]
|
||||
)
|
||||
random_json: pydantic.Json = ormar.JSON(choices=["aa", '{"aa":"bb"}'])
|
||||
random_json: pydantic.Json = ormar.JSON(choices=["aa", '{"aa": "bb"}'])
|
||||
random_uuid: uuid.UUID = ormar.UUID(choices=[uuid1, uuid2])
|
||||
enum_string: str = ormar.String(max_length=100, choices=list(EnumTest))
|
||||
blob_col: bytes = ormar.LargeBinary(max_length=100000, choices=[blob, blob2])
|
||||
@ -116,7 +115,7 @@ def test_all_endpoints():
|
||||
"expire_datetime": "2022-05-01T12:30:00",
|
||||
"random_val": 3.5,
|
||||
"random_decimal": 12.4,
|
||||
"random_json": '{"aa":"bb"}',
|
||||
"random_json": '{"aa": "bb"}',
|
||||
"random_uuid": str(uuid1),
|
||||
"enum_string": EnumTest.val1.value,
|
||||
"blob_col": blob.decode("utf-8"),
|
||||
|
||||
@ -131,10 +131,6 @@ def test_all_endpoints():
|
||||
assert items[0].name == "New name"
|
||||
assert items[0].category.name is None
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(items[0].category.load())
|
||||
assert items[0].category.name is not None
|
||||
|
||||
response = client.get(f"/items/{item.pk}")
|
||||
new_item = Item(**response.json())
|
||||
assert new_item == item
|
||||
|
||||
@ -133,9 +133,7 @@ class Car2(ormar.Model):
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=50)
|
||||
owner: Person = ormar.ForeignKey(Person, related_name="owned")
|
||||
co_owners: List[Person] = ormar.ManyToMany(
|
||||
Person, related_name="coowned",
|
||||
)
|
||||
co_owners: List[Person] = ormar.ManyToMany(Person, related_name="coowned")
|
||||
created_date: datetime.datetime = ormar.DateTime(default=datetime.datetime.now)
|
||||
|
||||
|
||||
@ -204,7 +202,7 @@ def test_field_redefining_in_concrete_models():
|
||||
assert changed_field.get_alias() == "creation_date"
|
||||
assert any(x.name == "creation_date" for x in RedefinedField.Meta.table.columns)
|
||||
assert isinstance(
|
||||
RedefinedField.Meta.table.columns["creation_date"].type, sa.sql.sqltypes.String,
|
||||
RedefinedField.Meta.table.columns["creation_date"].type, sa.sql.sqltypes.String
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -95,8 +95,7 @@ def test_field_redefining_in_second_raises_error():
|
||||
)
|
||||
assert any(x.name == "creation_date" for x in RedefinedField2.Meta.table.columns)
|
||||
assert isinstance(
|
||||
RedefinedField2.Meta.table.columns["creation_date"].type,
|
||||
sa.sql.sqltypes.String,
|
||||
RedefinedField2.Meta.table.columns["creation_date"].type, sa.sql.sqltypes.String
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -62,18 +62,18 @@ async def cleanup():
|
||||
@pytest.mark.asyncio
|
||||
async def test_creating_a_position(cleanup):
|
||||
async with database:
|
||||
instance = PositionOrm(name="my_pos", x=1.0, y=2.0, degrees=3.0,)
|
||||
instance = PositionOrm(name="my_pos", x=1.0, y=2.0, degrees=3.0)
|
||||
await instance.save()
|
||||
assert instance.saved
|
||||
assert instance.name == "my_pos"
|
||||
|
||||
instance2 = PositionOrmDef(x=1.0, y=2.0, degrees=3.0,)
|
||||
instance2 = PositionOrmDef(x=1.0, y=2.0, degrees=3.0)
|
||||
await instance2.save()
|
||||
assert instance2.saved
|
||||
assert instance2.name is not None
|
||||
assert len(instance2.name) == 12
|
||||
|
||||
instance3 = PositionOrmDef(x=1.0, y=2.0, degrees=3.0,)
|
||||
instance3 = PositionOrmDef(x=1.0, y=2.0, degrees=3.0)
|
||||
await instance3.save()
|
||||
assert instance3.saved
|
||||
assert instance3.name is not None
|
||||
|
||||
@ -27,7 +27,7 @@ class Mol(ormar.Model):
|
||||
class Meta(BaseMeta):
|
||||
tablename = "mols"
|
||||
|
||||
id: str = ormar.UUID(primary_key=True, index=True, uuid_format="hex")
|
||||
id: uuid.UUID = ormar.UUID(primary_key=True, index=True, uuid_format="hex")
|
||||
smiles: str = ormar.String(nullable=False, unique=True, max_length=256)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
@ -117,7 +117,7 @@ def test_operator_return_proper_filter_action(method, expected, expected_value):
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("method, expected_direction", [("asc", ""), ("desc", "desc"),])
|
||||
@pytest.mark.parametrize("method, expected_direction", [("asc", ""), ("desc", "desc")])
|
||||
def test_operator_return_proper_order_action(method, expected_direction):
|
||||
action = getattr(Product.name, method)()
|
||||
assert action.source_model == Product
|
||||
|
||||
@ -126,7 +126,7 @@ class Country(ormar.Model):
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(
|
||||
max_length=9, choices=country_name_choices, default="Canada",
|
||||
max_length=9, choices=country_name_choices, default="Canada"
|
||||
)
|
||||
taxed: bool = ormar.Boolean(choices=country_taxed_choices, default=True)
|
||||
country_code: int = ormar.Integer(
|
||||
|
||||
@ -19,9 +19,9 @@ class OverwriteTest(ormar.Model):
|
||||
database = database
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
my_int: str = ormar.Integer(overwrite_pydantic_type=PositiveInt)
|
||||
my_int: int = ormar.Integer(overwrite_pydantic_type=PositiveInt)
|
||||
constraint_dict: Json = ormar.JSON(
|
||||
overwrite_pydantic_type=Optional[Json[Dict[str, int]]]
|
||||
overwrite_pydantic_type=Optional[Json[Dict[str, int]]] # type: ignore
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ class ModelTest(ormar.Model):
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=200)
|
||||
url: HttpUrl = "https://www.example.com"
|
||||
url: HttpUrl = "https://www.example.com" # type: ignore
|
||||
number: Optional[PaymentCardNumber]
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ class ModelTest2(ormar.Model):
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=200)
|
||||
url: HttpUrl = "https://www.example2.com"
|
||||
url: HttpUrl = "https://www.example2.com" # type: ignore
|
||||
number: PaymentCardNumber = Field(default_factory=get_number)
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class ModelTest3(ormar.Model):
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=200)
|
||||
url: HttpUrl = "https://www.example3.com"
|
||||
url: HttpUrl = "https://www.example3.com" # type: ignore
|
||||
number: PaymentCardNumber
|
||||
pydantic_test: PydanticTest
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ class SecondaryModel(ormar.Model):
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
primary_model: PrimaryModel = ormar.ForeignKey(
|
||||
PrimaryModel, related_name="secondary_models",
|
||||
PrimaryModel, related_name="secondary_models"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class DataSourceTable(ormar.Model):
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=200, index=True)
|
||||
source: Optional[DataSource] = ormar.ForeignKey(
|
||||
DataSource, name="source_id", related_name="tables", ondelete="CASCADE",
|
||||
DataSource, name="source_id", related_name="tables", ondelete="CASCADE"
|
||||
)
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class DataSourceTableColumn(ormar.Model):
|
||||
name: str = ormar.String(max_length=200, index=True)
|
||||
data_type: str = ormar.String(max_length=200)
|
||||
table: Optional[DataSourceTable] = ormar.ForeignKey(
|
||||
DataSourceTable, name="table_id", related_name="columns", ondelete="CASCADE",
|
||||
DataSourceTable, name="table_id", related_name="columns", ondelete="CASCADE"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ async def test_or_filters():
|
||||
)
|
||||
)
|
||||
& (Book.title.startswith("The"))
|
||||
),
|
||||
)
|
||||
)
|
||||
.all()
|
||||
)
|
||||
|
||||
@ -95,6 +95,6 @@ async def test_add_students():
|
||||
assert user.attending is not None
|
||||
assert len(user.attending) > 0
|
||||
|
||||
query = Session.objects.prefetch_related(["students", "teacher",])
|
||||
query = Session.objects.prefetch_related(["students", "teacher"])
|
||||
sessions = await query.all()
|
||||
assert len(sessions) == 5
|
||||
|
||||
@ -56,7 +56,7 @@ class SecondaryModel(ormar.Model):
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
name: str = ormar.String(max_length=100)
|
||||
primary_model: PrimaryModel = ormar.ForeignKey(
|
||||
PrimaryModel, related_name="secondary_models",
|
||||
PrimaryModel, related_name="secondary_models"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -6,14 +6,7 @@ import pytest
|
||||
import sqlalchemy
|
||||
|
||||
import ormar
|
||||
from ormar import (
|
||||
post_delete,
|
||||
post_save,
|
||||
post_update,
|
||||
pre_delete,
|
||||
pre_save,
|
||||
pre_update,
|
||||
)
|
||||
from ormar import post_delete, post_save, post_update, pre_delete, pre_save, pre_update
|
||||
from ormar.exceptions import SignalDefinitionError
|
||||
from tests.settings import DATABASE_URL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user