38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
# This file is part of the Open Parts Database software
|
|
# Copyright (C) 2022 Valentin Lorentz
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it under the
|
|
# terms of the GNU Affero General Public License version 3, as published by the
|
|
# Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
# PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License along with
|
|
# this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
Tests the ORM
|
|
"""
|
|
|
|
import textwrap
|
|
|
|
from opdb.db import models
|
|
|
|
|
|
def test_db_schema():
|
|
"""Tests generation of the DB schema for WebPageSnapshot."""
|
|
assert models.WebPageSnapshot.db_schema() == textwrap.dedent(
|
|
"""\
|
|
CREATE TABLE IF NOT EXISTS web_page_snapshot (
|
|
url text NOT NULL,
|
|
snapshot_date timestamptz NOT NULL,
|
|
snapshot_url text,
|
|
retrieved_at timestamptz NOT NULL,
|
|
response_headers jsonb NOT NULL,
|
|
content bytea NOT NULL
|
|
);
|
|
CREATE UNIQUE INDEX IF NOT EXISTS web_page_snapshot_pk ON web_page_snapshot (url, snapshot_date);""" # noqa
|
|
)
|