refactor fields into a package

This commit is contained in:
collerek
2020-08-11 17:34:19 +02:00
parent 704e83fed0
commit 867fc691f7
13 changed files with 335 additions and 290 deletions

View File

@ -4,6 +4,7 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
import orm
import orm.fields.foreign_key
from tests.settings import DATABASE_URL
app = FastAPI()
@ -28,7 +29,7 @@ class Item(orm.Model):
id = orm.Integer(primary_key=True)
name = orm.String(length=100)
category = orm.ForeignKey(Category, nullable=True)
category = orm.fields.foreign_key.ForeignKey(Category, nullable=True)
@app.post("/items/", response_model=Item)

View File

@ -3,6 +3,7 @@ import pytest
import sqlalchemy
import orm
import orm.fields.foreign_key
from orm.exceptions import NoMatch, MultipleMatches, RelationshipInstanceError
from tests.settings import DATABASE_URL
@ -25,7 +26,7 @@ class Track(orm.Model):
__database__ = database
id = orm.Integer(primary_key=True)
album = orm.ForeignKey(Album)
album = orm.fields.foreign_key.ForeignKey(Album)
title = orm.String(length=100)
position = orm.Integer()
@ -45,7 +46,7 @@ class Team(orm.Model):
__database__ = database
id = orm.Integer(primary_key=True)
org = orm.ForeignKey(Organisation)
org = orm.fields.foreign_key.ForeignKey(Organisation)
name = orm.String(length=100)
@ -55,7 +56,7 @@ class Member(orm.Model):
__database__ = database
id = orm.Integer(primary_key=True)
team = orm.ForeignKey(Team)
team = orm.fields.foreign_key.ForeignKey(Team)
email = orm.String(length=100)

View File

@ -5,6 +5,7 @@ import pytest
import sqlalchemy
import orm
import orm.fields.foreign_key
from tests.settings import DATABASE_URL
database = databases.Database(DATABASE_URL, force_rollback=True)
@ -27,7 +28,7 @@ class SchoolClass(orm.Model):
id = orm.Integer(primary_key=True)
name = orm.String(length=100)
department = orm.ForeignKey(Department, nullable=False)
department = orm.fields.foreign_key.ForeignKey(Department, nullable=False)
class Category(orm.Model):
@ -46,8 +47,8 @@ class Student(orm.Model):
id = orm.Integer(primary_key=True)
name = orm.String(length=100)
schoolclass = orm.ForeignKey(SchoolClass)
category = orm.ForeignKey(Category, nullable=True)
schoolclass = orm.fields.foreign_key.ForeignKey(SchoolClass)
category = orm.fields.foreign_key.ForeignKey(Category, nullable=True)
class Teacher(orm.Model):
@ -57,8 +58,8 @@ class Teacher(orm.Model):
id = orm.Integer(primary_key=True)
name = orm.String(length=100)
schoolclass = orm.ForeignKey(SchoolClass)
category = orm.ForeignKey(Category, nullable=True)
schoolclass = orm.fields.foreign_key.ForeignKey(SchoolClass)
category = orm.fields.foreign_key.ForeignKey(Category, nullable=True)
@pytest.fixture(scope='module')