fix tests

This commit is contained in:
SvyatoslavArtymovych 2023-04-26 17:57:40 +03:00
parent 7a885f11dd
commit 2524b34f09
3 changed files with 7 additions and 4 deletions

View File

@ -8,7 +8,7 @@ class Collection(BaseModel):
# need to redeclare id to use it in the parrent relationship
id = db.Column(db.Integer, primary_key=True)
label = db.Column(db.String(1024), unique=False, nullable=False)
about = db.Column(db.Text, unique=False, nullable=False)
about = db.Column(db.Text, unique=False, nullable=True)
is_root = db.Column(db.Boolean, default=False)
is_leaf = db.Column(db.Boolean, default=False)

View File

@ -351,7 +351,7 @@ def collection_create(book_id: int):
if form.validate_on_submit():
label = form.label.data
collection: m.Collection = m.Collection.query.filter_by(
is_deleted=False, label=label, version_id=book.versions[-1]
is_deleted=False, label=label, version_id=book.versions[-1].id
).first()
if collection:
@ -408,7 +408,7 @@ def collection_edit(book_id: int, collection_id: int):
label = form.label.data
if (
m.Collection.query.filter_by(label=label, version_id=book.versions[-1])
m.Collection.query.filter_by(label=label, version_id=book.versions[-1].id)
.filter(m.Collection.id != collection_id)
.first()
):

View File

@ -218,11 +218,14 @@ def test_crud_collection(client: FlaskClient, runner: FlaskCliRunner):
collection: m.Collection = m.Collection.query.filter_by(
label="Test Collection #1 Label"
).first()
m.Collection(
label="Test Collection #2 Label", version_id=collection.version_id
).save()
response: Response = client.post(
f"/book/{book.id}/{collection.id}/edit",
data=dict(
label="Test Collection #1 Label",
label="Test Collection #2 Label",
),
follow_redirects=True,
)