Skip to content

Commit e763921

Browse files
committed
updated teststo include job tables
1 parent 2d20143 commit e763921

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/test_migrations.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def test_upgrade_head(alembic_cfg, alembic_engine):
3535
tables = inspector.get_table_names()
3636
assert "template" in tables
3737
assert "formsubmission" in tables
38+
assert "job" in tables
3839
assert "alembic_version" in tables
3940

4041

@@ -46,6 +47,7 @@ def test_downgrade_base(alembic_cfg, alembic_engine):
4647
tables = inspector.get_table_names()
4748
assert "template" not in tables
4849
assert "formsubmission" not in tables
50+
assert "job" not in tables
4951

5052

5153
def test_round_trip(alembic_cfg, alembic_engine):
@@ -83,3 +85,44 @@ def test_formsubmission_fk(alembic_cfg, alembic_engine):
8385
assert len(fks) == 1
8486
assert fks[0]["referred_table"] == "template"
8587
assert fks[0]["referred_columns"] == ["id"]
88+
89+
90+
def test_job_columns(alembic_cfg, alembic_engine):
91+
command.upgrade(alembic_cfg, "head")
92+
93+
inspector = inspect(alembic_engine)
94+
columns = {c["name"] for c in inspector.get_columns("job")}
95+
assert columns == {
96+
"id",
97+
"job_id",
98+
"celery_task_id",
99+
"job_type",
100+
"template_id",
101+
"input_text",
102+
"status",
103+
"progress_percent",
104+
"result_url",
105+
"error",
106+
"model",
107+
"created_at",
108+
"updated_at",
109+
}
110+
111+
112+
def test_job_indexes(alembic_cfg, alembic_engine):
113+
command.upgrade(alembic_cfg, "head")
114+
115+
inspector = inspect(alembic_engine)
116+
indexes = {ix["name"]: ix for ix in inspector.get_indexes("job")}
117+
assert indexes["ix_job_job_id"]["unique"]
118+
assert not indexes["ix_job_celery_task_id"]["unique"]
119+
120+
121+
def test_job_fk(alembic_cfg, alembic_engine):
122+
command.upgrade(alembic_cfg, "head")
123+
124+
inspector = inspect(alembic_engine)
125+
fks = inspector.get_foreign_keys("job")
126+
assert len(fks) == 1
127+
assert fks[0]["referred_table"] == "template"
128+
assert fks[0]["referred_columns"] == ["id"]

0 commit comments

Comments
 (0)