Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions invenio_oaiserver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# Copyright (C) 2015-2025 CERN.
# Copyright (C) 2022-2026 Graz University of Technology.
# Copyright (C) 2024 KTH Royal Institute of Technology.
# Copyright (C) 2026 CESNET z.s.p.o.
#
# 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.

"""Models for storing information about OAIServer state."""

import sqlalchemy as sa
from invenio_db import db
from invenio_i18n import lazy_gettext as _
from sqlalchemy.orm import validates
Expand Down Expand Up @@ -68,6 +70,7 @@ class OAISet(db.Model, db.Timestamp):
system_created = db.Column(
db.Boolean,
nullable=False,
server_default=sa.sql.expression.literal(False),
info=dict(
label=_("System created"),
description=_("System created set"),
Expand Down
36 changes: 36 additions & 0 deletions tests/test_alembic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2026 CESNET z.s.p.o.
#
# Invenio-oaiserver is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Test invenio-oaiserver alembic."""

import pytest
from invenio_db import db
from invenio_db.utils import alembic_test_context, drop_alembic_version_table


def test_alembic(app):
"""Test alembic recipes."""
ext = app.extensions["invenio-db"]

if db.engine.name == "sqlite":
raise pytest.skip("Upgrades are not supported on SQLite.")

app.config["ALEMBIC_CONTEXT"] = alembic_test_context()

# Check that this package's SQLAlchemy models have been properly registered
tables = [x for x in db.metadata.tables]
assert "oaiserver_set" in tables

# Check that Alembic agrees that there's no further tables to create.
assert len(ext.alembic.compare_metadata()) == 0

# Drop everything and recreate tables all with Alembic
db.drop_all()
drop_alembic_version_table()
ext.alembic.upgrade()
assert len(ext.alembic.compare_metadata()) == 0

drop_alembic_version_table()
Loading