From d03b808b95f110ca3ec6bab5ab771c79ecd21400 Mon Sep 17 00:00:00 2001 From: Chandragupt Singh Date: Wed, 7 Jan 2026 00:24:03 +0530 Subject: [PATCH 1/3] Add XMLTV regression test --- install/sample_db.py | 8 +- .../eb7303e132c0_add_xmltv_regression_test.py | 99 +++++++++++++++++++ tests/base.py | 7 +- 3 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 migrations/versions/eb7303e132c0_add_xmltv_regression_test.py diff --git a/install/sample_db.py b/install/sample_db.py index ec5f0546..590c53aa 100644 --- a/install/sample_db.py +++ b/install/sample_db.py @@ -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 @@ -42,7 +41,7 @@ def run(): regression_tests = [ RegressionTest(1, '-autoprogram -out=ttxt -latin1', InputType.file, OutputType.file, 3, 10), - RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla', InputType.file, OutputType.file, 1, 10) + RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla', InputType.file, OutputType.file, 1, 10), ] entries.extend(regression_tests) @@ -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) @@ -63,5 +62,4 @@ def run(): print("Entry already exists!", entry, flush=True) db.rollback() - run() diff --git a/migrations/versions/eb7303e132c0_add_xmltv_regression_test.py b/migrations/versions/eb7303e132c0_add_xmltv_regression_test.py new file mode 100644 index 00000000..38c0c1f1 --- /dev/null +++ b/migrations/versions/eb7303e132c0_add_xmltv_regression_test.py @@ -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}, + ) diff --git a/tests/base.py b/tests/base.py index 8bb719a9..ad407463 100644 --- a/tests/base.py +++ b/tests/base.py @@ -308,19 +308,20 @@ def setUp(self): regression_tests = [ RegressionTest(1, "-autoprogram -out=ttxt -latin1 -2", InputType.file, OutputType.file, 3, 10), - RegressionTest(2, "-autoprogram -out=ttxt -latin1 -ucla", InputType.file, OutputType.file, 1, 10) + RegressionTest(2, "-autoprogram -out=ttxt -latin1 -ucla", InputType.file, OutputType.file, 1, 10), ] g.db.add_all(regression_tests) g.db.commit() 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", "") + RegressionTestOutput(2, "sample_out2", ".srt", ""), ] g.db.add_all(regression_test_outputs) - g.db.commit() + g.db.commit() rtof = RegressionTestOutputFiles("bluedabadee", 2) g.db.add(rtof) From 08af73700dd5dbefb27e98c571c0d8fd44c119a4 Mon Sep 17 00:00:00 2001 From: Chandragupt Singh Date: Fri, 9 Jan 2026 16:29:34 +0530 Subject: [PATCH 2/3] chore: clean up trailing commas and whitespace in test fixtures --- install/sample_db.py | 2 +- tests/base.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/install/sample_db.py b/install/sample_db.py index 590c53aa..012d9c1d 100644 --- a/install/sample_db.py +++ b/install/sample_db.py @@ -41,7 +41,7 @@ def run(): regression_tests = [ RegressionTest(1, '-autoprogram -out=ttxt -latin1', InputType.file, OutputType.file, 3, 10), - RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla', InputType.file, OutputType.file, 1, 10), + RegressionTest(2, '-autoprogram -out=ttxt -latin1 -ucla', InputType.file, OutputType.file, 1, 10) ] entries.extend(regression_tests) diff --git a/tests/base.py b/tests/base.py index ad407463..383d515b 100644 --- a/tests/base.py +++ b/tests/base.py @@ -308,7 +308,7 @@ def setUp(self): regression_tests = [ RegressionTest(1, "-autoprogram -out=ttxt -latin1 -2", InputType.file, OutputType.file, 3, 10), - RegressionTest(2, "-autoprogram -out=ttxt -latin1 -ucla", InputType.file, OutputType.file, 1, 10), + RegressionTest(2, "-autoprogram -out=ttxt -latin1 -ucla", InputType.file, OutputType.file, 1, 10) ] g.db.add_all(regression_tests) g.db.commit() @@ -318,10 +318,10 @@ def setUp(self): regression_test_outputs = [ RegressionTestOutput(1, "sample_out1", ".srt", ""), - RegressionTestOutput(2, "sample_out2", ".srt", ""), + RegressionTestOutput(2, "sample_out2", ".srt", "") ] g.db.add_all(regression_test_outputs) - g.db.commit() + g.db.commit() rtof = RegressionTestOutputFiles("bluedabadee", 2) g.db.add(rtof) From 0d8ad55466586dd97498a6494fa7f4ae75303d82 Mon Sep 17 00:00:00 2001 From: Chandragupt Singh Date: Tue, 13 Jan 2026 20:22:22 +0530 Subject: [PATCH 3/3] revert: drop unrelated .srt normalization from this PR --- install/sample_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/sample_db.py b/install/sample_db.py index 012d9c1d..90d85135 100644 --- a/install/sample_db.py +++ b/install/sample_db.py @@ -49,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)