Added poetry integration.

Description:
* Fixed github actions;
* Removed requirements.txt;
* Fixed CONTRIBUTING.md;
* Fixed black and flake8.

Signed-off-by: Pavel <win10@list.ru>
This commit is contained in:
Pavel
2021-10-08 15:57:22 +04:00
parent 80c6ff38a1
commit b2541bed1e
52 changed files with 2685 additions and 377 deletions

View File

@ -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
)

View File

@ -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="")

View File

@ -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)

View File

@ -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())

View File

@ -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
)

View File

@ -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
)

View File

@ -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

View File

@ -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

View File

@ -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(

View File

@ -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"
)

View File

@ -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"
)

View File

@ -130,7 +130,7 @@ async def test_or_filters():
)
)
& (Book.title.startswith("The"))
),
)
)
.all()
)

View File

@ -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

View File

@ -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"
)

View File

@ -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