Skip to content

Commit b3f1c90

Browse files
committed
fix(copy tests): bugs when copying multiple and table tests
1 parent ac2567c commit b3f1c90

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

testgen/commands/run_profiling_bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def run_profiling_in_background(table_group_id):
214214
empty_cache()
215215
background_thread = threading.Thread(
216216
target=run_profiling_queries,
217-
args=(table_group_id, session.auth.user_display),
217+
args=(table_group_id, session.auth.user_display if session.auth else None),
218218
)
219219
background_thread.start()
220220
else:

testgen/common/models/test_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TestType(Entity):
147147
class TestDefinition(Entity):
148148
__tablename__ = "test_definitions"
149149

150-
id: UUID = Column(postgresql.UUID(as_uuid=True), default=uuid4)
150+
id: UUID = Column(postgresql.UUID(as_uuid=True), server_default=text("gen_random_uuid()"))
151151
cat_test_id: int = Column(BigInteger, Identity(), primary_key=True)
152152
table_groups_id: UUID = Column(postgresql.UUID(as_uuid=True))
153153
profile_run_id: UUID = Column(postgresql.UUID(as_uuid=True))

testgen/ui/views/test_definitions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pandas as pd
88
import streamlit as st
9-
from sqlalchemy import asc, func, tuple_
9+
from sqlalchemy import and_, asc, func, or_, tuple_
1010
from streamlit.delta_generator import DeltaGenerator
1111
from streamlit_extras.no_default_selectbox import selectbox
1212

@@ -1184,13 +1184,16 @@ def get_test_definitions_collision(
11841184
target_table_group_id: str,
11851185
target_test_suite_id: str,
11861186
) -> pd.DataFrame:
1187+
table_tests = [(item["table_name"], item["test_type"]) for item in test_definitions if item["column_name"] is None]
1188+
column_tests = [(item["table_name"], item["column_name"], item["test_type"]) for item in test_definitions if item["column_name"] is not None]
11871189
results = TestDefinition.select_minimal_where(
11881190
TestDefinition.table_groups_id == target_table_group_id,
11891191
TestDefinition.test_suite_id == target_test_suite_id,
11901192
TestDefinition.last_auto_gen_date.isnot(None),
1191-
tuple_(TestDefinition.table_name, TestDefinition.column_name, TestDefinition.test_type).in_(
1192-
[(item["table_name"], item["column_name"], item["test_type"]) for item in test_definitions]
1193-
),
1193+
or_(
1194+
tuple_(TestDefinition.table_name, TestDefinition.column_name, TestDefinition.test_type).in_(column_tests),
1195+
and_(tuple_(TestDefinition.table_name, TestDefinition.test_type).in_(table_tests), TestDefinition.column_name.is_(None)),
1196+
)
11941197
)
11951198
return to_dataframe(results, TestDefinitionMinimal.columns())
11961199

0 commit comments

Comments
 (0)