(core) Test undo for all Python summary table tests

Summary:
Undo often leads to errors, especially with summary tables. One example is here: https://grist.slack.com/archives/C069RUP71/p1662564341132349

This diff simply decorates all relevant tests in 3 files testing summary tables with `@test_engine.test_undo`. This didn't catch any new bugs or reveal the problem in the thread above, but it seems good to have.

Test Plan: this

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3624
This commit is contained in:
Alex Hall 2022-09-07 17:41:30 +02:00
parent 2438a63255
commit 0a2bc56938
3 changed files with 22 additions and 1 deletions

View File

@ -73,6 +73,7 @@ class TestSummary(test_engine.EngineTestCase):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_create_view_section(self): def test_create_view_section(self):
self.load_sample(self.sample) self.load_sample(self.sample)
@ -245,6 +246,7 @@ class Address:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_table_reuse(self): def test_summary_table_reuse(self):
# Test that we'll reuse a suitable summary table when already available. # Test that we'll reuse a suitable summary table when already available.
@ -316,6 +318,7 @@ class Address:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_no_invalid_reuse(self): def test_summary_no_invalid_reuse(self):
# Verify that if we have some summary tables for one table, they don't mistakenly get used # Verify that if we have some summary tables for one table, they don't mistakenly get used
# when we need a summary for another table. # when we need a summary for another table.
@ -399,6 +402,7 @@ class Address:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_updates(self): def test_summary_updates(self):
# Verify that summary tables update automatically when we change a value used in a summary # Verify that summary tables update automatically when we change a value used in a summary
# formula; or a value in a group-by column; or add/remove a record; that records get # formula; or a value in a group-by column; or add/remove a record; that records get
@ -516,6 +520,7 @@ class Address:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_table_rename(self): def test_table_rename(self):
# Verify that summary tables keep working and updating when source table is renamed. # Verify that summary tables keep working and updating when source table is renamed.
@ -557,6 +562,7 @@ class Address:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_table_rename_multiple(self): def test_table_rename_multiple(self):
# Similar to the above, verify renames, but now with two summary tables. # Similar to the above, verify renames, but now with two summary tables.
@ -596,6 +602,7 @@ class Address:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_change_summary_formula(self): def test_change_summary_formula(self):
# Verify that changing a summary formula affects all group-by variants, and adding a new # Verify that changing a summary formula affects all group-by variants, and adding a new
# summary table gets the changed formula. # summary table gets the changed formula.
@ -706,6 +713,7 @@ class Address:
]) ])
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_convert_source_column(self): def test_convert_source_column(self):
# Verify that we can convert the type of a column when there is a summary table using that # Verify that we can convert the type of a column when there is a summary table using that
# column to group by. Since converting generates extra summary records, this may cause bugs. # column to group by. Since converting generates extra summary records, this may cause bugs.

View File

@ -19,6 +19,7 @@ class TestSummary2(test_engine.EngineTestCase):
starting_table_data = test_summary.TestSummary.starting_table_data starting_table_data = test_summary.TestSummary.starting_table_data
@test_engine.test_undo
def test_add_summary_formula(self): def test_add_summary_formula(self):
# Verify that we can add a summary formula; that new sections automatically get columns # Verify that we can add a summary formula; that new sections automatically get columns
# matching the source table, and not other columns. Check that group-by columns override # matching the source table, and not other columns. Check that group-by columns override
@ -162,6 +163,7 @@ class TestSummary2(test_engine.EngineTestCase):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_col_rename(self): def test_summary_col_rename(self):
# Verify that renaming a column in a source table causes appropriate renames in the summary # Verify that renaming a column in a source table causes appropriate renames in the summary
# tables, and that renames of group-by columns in summary tables are disallowed. # tables, and that renames of group-by columns in summary tables are disallowed.
@ -328,6 +330,7 @@ class TestSummary2(test_engine.EngineTestCase):
[21, 'foo3', True, 'WidgetOptions2'], [21, 'foo3', True, 'WidgetOptions2'],
], rows=lambda r: r.colId in ('foo2', 'foo3')) ], rows=lambda r: r.colId in ('foo2', 'foo3'))
@test_engine.test_undo
def test_summary_col_rename_conflict(self): def test_summary_col_rename_conflict(self):
sample = testutil.parse_test_sample({ sample = testutil.parse_test_sample({
"SCHEMA": [ "SCHEMA": [
@ -418,6 +421,7 @@ class TestSummary2(test_engine.EngineTestCase):
tables = [table1, fake_summary, summary_by_a_and_b, summary_by_a] tables = [table1, fake_summary, summary_by_a_and_b, summary_by_a]
self.assertTables(tables) self.assertTables(tables)
@test_engine.test_undo
def test_source_table_rename_conflict(self): def test_source_table_rename_conflict(self):
sample = testutil.parse_test_sample({ sample = testutil.parse_test_sample({
"SCHEMA": [ "SCHEMA": [
@ -469,6 +473,7 @@ class TestSummary2(test_engine.EngineTestCase):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_restrictions(self): def test_restrictions(self):
# Verify various restrictions on summary tables # Verify various restrictions on summary tables
# (1) no adding/removing/renaming non-formula columns. # (1) no adding/removing/renaming non-formula columns.
@ -553,6 +558,7 @@ class TestSummary2(test_engine.EngineTestCase):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_update_summary_section(self): def test_update_summary_section(self):
# Verify that we can change the group-by for a view section, and that unused tables get # Verify that we can change the group-by for a view section, and that unused tables get
# removed. # removed.
@ -876,6 +882,7 @@ class TestSummary2(test_engine.EngineTestCase):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_update_groupby_override(self): def test_update_groupby_override(self):
# Verify that if we add a group-by column that conflicts with a formula, group-by column wins. # Verify that if we add a group-by column that conflicts with a formula, group-by column wins.
@ -939,6 +946,7 @@ class TestSummary2(test_engine.EngineTestCase):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_cleanup_on_view_remove(self): def test_cleanup_on_view_remove(self):
# Verify that if we remove a view, that unused summary tables get cleaned up. # Verify that if we remove a view, that unused summary tables get cleaned up.
@ -1067,6 +1075,7 @@ class TestSummary2(test_engine.EngineTestCase):
]) ])
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_detach_summary_section(self): def test_detach_summary_section(self):
# Verify that "DetachSummaryViewSection" useraction works correctly. # Verify that "DetachSummaryViewSection" useraction works correctly.
@ -1185,6 +1194,7 @@ class TestSummary2(test_engine.EngineTestCase):
]) ])
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_of_detached(self): def test_summary_of_detached(self):
# Verify that we can make a summary table of a detached table. This is mainly to ensure that # Verify that we can make a summary table of a detached table. This is mainly to ensure that
# we handle well the presence of columns like 'group' and 'count' in the source table. # we handle well the presence of columns like 'group' and 'count' in the source table.

View File

@ -5,7 +5,7 @@ import column
import logger import logger
import lookup import lookup
import testutil import testutil
from test_engine import EngineTestCase, Table, Column from test_engine import EngineTestCase, Table, Column, test_undo
log = logger.Logger(__name__, logger.INFO) log = logger.Logger(__name__, logger.INFO)
@ -35,6 +35,7 @@ class TestSummaryChoiceList(EngineTestCase):
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@test_undo
def test_summary_by_choice_list(self): def test_summary_by_choice_list(self):
self.load_sample(self.sample) self.load_sample(self.sample)
@ -306,6 +307,7 @@ class TestSummaryChoiceList(EngineTestCase):
self.assertTableData('Table1', data=summary_data, cols="subset") self.assertTableData('Table1', data=summary_data, cols="subset")
@test_undo
def test_change_choice_to_choicelist(self): def test_change_choice_to_choicelist(self):
sample = testutil.parse_test_sample({ sample = testutil.parse_test_sample({
"SCHEMA": [ "SCHEMA": [
@ -369,6 +371,7 @@ class TestSummaryChoiceList(EngineTestCase):
self.assertTables([starting_table, summary_table]) self.assertTables([starting_table, summary_table])
self.assertTableData('Source_summary_choices1', data=data) self.assertTableData('Source_summary_choices1', data=data)
@test_undo
def test_rename_choices(self): def test_rename_choices(self):
self.load_sample(self.sample) self.load_sample(self.sample)