Skip to content

Commit

Permalink
tests: updated tests and added alembic recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatimah committed Feb 19, 2024
1 parent 67f69a8 commit 31197c7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
37 changes: 37 additions & 0 deletions invenio_pages/alembic/b0f93ca4a147_add_has_custom_view_to_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# This file is part of Invenio.
# Copyright (C) 2016-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Add has_custom_view to pages."""

import sqlalchemy as sa
import sqlalchemy_utils
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "b0f93ca4a147"
down_revision = "145402e8523a"
branch_labels = ()
depends_on = None


def upgrade():
"""Upgrade database."""
# Add the new column
op.add_column(
"pages_page",
sa.Column("has_custom_view", sa.Boolean(), nullable=True, default="False"),
)

# ### end Alembic commands ###


def downgrade():
"""Downgrade database."""
# Drop the column
op.drop_column("pages_page", "has_custom_view")
# ### end Alembic commands ###
5 changes: 4 additions & 1 deletion tests/records/test_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

def test_page_repr(module_scoped_pages_fixture, base_app):
dog_page = Page.get_by_url("/dogs/shiba")
assert dog_page.__repr__() == "URL: /dogs/shiba, title: Page for doge!"
assert (
dog_page.__repr__()
== "URL: /dogs/shiba, title: Page for doge!, has_custom_view: False"
)


def test_page_versions(module_scoped_pages_fixture, base_app, db):
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_page_content(module_scoped_pages_fixture, base_client):
"content": "Generic dog.",
"id": "1",
"template_name": "invenio_pages/default.html",
"has_custom_view": False,
"links": {"self": "https://127.0.0.1:5000/api/pages/1"},
}
assert json == expected_data
Expand All @@ -47,6 +48,7 @@ def test_html_content(module_scoped_pages_fixture, base_client):
"content": "<h1>HTML aware dog.</h1>.\n" '<p class="test">paragraph<br /></p>',
"id": "4",
"template_name": "invenio_pages/default.html",
"has_custom_view": False,
"links": {"self": "https://127.0.0.1:5000/api/pages/4"},
}
assert json == expected_data
Expand Down
2 changes: 2 additions & 0 deletions tests/services/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_page_read(module_scoped_pages_fixture, simple_user_identity):
"content": "Generic dog.",
"id": "1",
"template_name": "invenio_pages/default.html",
"has_custom_view": False,
"links": {"self": "https://127.0.0.1:5000/api/pages/1"},
}
assert page == expected_data
Expand All @@ -50,6 +51,7 @@ def test_page_read_by_url(module_scoped_pages_fixture, simple_user_identity):
"content": "Generic dog.",
"id": "1",
"template_name": "invenio_pages/default.html",
"has_custom_view": False,
"links": {"self": "https://127.0.0.1:5000/api/pages/1"},
}
assert page == expected_data
Expand Down

0 comments on commit 31197c7

Please sign in to comment.