Skip to content
Open
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
6 changes: 2 additions & 4 deletions install/sample_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))


def run():
from database import create_session
from mod_auth.models import User
Expand Down Expand Up @@ -50,8 +49,8 @@ def run():
entries.append(gen_data)

regression_test_output = [
RegressionTestOutput(1, "test1", "srt", "test1.srt"),
RegressionTestOutput(2, "test2", "srt", "test2.srt")
RegressionTestOutput(1, "test1", ".srt", "test1.srt"),
RegressionTestOutput(2, "test2", ".srt", "test2.srt")
]
entries.extend(regression_test_output)

Expand All @@ -63,5 +62,4 @@ def run():
print("Entry already exists!", entry, flush=True)
db.rollback()


run()
99 changes: 99 additions & 0 deletions migrations/versions/eb7303e132c0_add_xmltv_regression_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""add_xmltv_regression_test

Revision ID: eb7303e132c0
Revises: 7793881905c5
Create Date: 2026-01-06 21:43:46.009899

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'eb7303e132c0'
down_revision = '7793881905c5'
branch_labels = None
depends_on = None


def upgrade():
conn = op.get_bind()

# 1. Check if the XMLTV regression test already exists
existing_test = conn.execute(
sa.text(
"SELECT id FROM regression_test "
"WHERE sample_id = 187 AND command = '--xmltv=1 --out=null'"
)
).fetchone()

if existing_test is not None:
# Already present, nothing to do
return

# 2. Insert regression test
conn.execute(
sa.text(
"""
INSERT INTO regression_test
(sample_id, command, input_type, output_type, expected_rc, active)
VALUES
(187, '--xmltv=1 --out=null', 'file', 'null', 5, 0)
"""
)
)

# 3. Fetch newly created test id
test_id = conn.execute(
sa.text(
"SELECT id FROM regression_test "
"WHERE sample_id = 187 AND command = '--xmltv=1 --out=null'"
)
).fetchone()[0]

# 4. Insert expected XMLTV output (exit-code based validation)
conn.execute(
sa.text(
"""
INSERT INTO regression_test_output
(regression_id, correct, correct_extension, expected_filename, ignore_parse_errors)
VALUES
(:test_id, 'ch29FullTS', '.xml', '', 1)
"""
),
{"test_id": test_id},
)



def downgrade():
conn = op.get_bind()

test_row = conn.execute(

sa.text(
"SELECT id FROM regression_test "
"WHERE sample_id = 187 AND command = '--xmltv=1 --out=null'"
)
).fetchone()

if test_row is None:
return

test_id = test_row[0]

# Remove output first (FK dependency)
conn.execute(
sa.text(
"DELETE FROM regression_test_output WHERE regression_id = :test_id"
),
{"test_id": test_id},
)

# Remove regression test
conn.execute(
sa.text(
"DELETE FROM regression_test WHERE id = :test_id"
),
{"test_id": test_id},
)
1 change: 1 addition & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ def setUp(self):

categories[0].regression_tests.append(regression_tests[0])
categories[2].regression_tests.append(regression_tests[1])

regression_test_outputs = [
RegressionTestOutput(1, "sample_out1", ".srt", ""),
RegressionTestOutput(2, "sample_out2", ".srt", "")
Expand Down