(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
pull/20/head
Alex Hall 2 years ago
parent 2438a63255
commit 0a2bc56938

@ -73,6 +73,7 @@ class TestSummary(test_engine.EngineTestCase):
#----------------------------------------------------------------------
@test_engine.test_undo
def test_create_view_section(self):
self.load_sample(self.sample)
@ -245,6 +246,7 @@ class Address:
#----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_table_reuse(self):
# 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):
# 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.
@ -399,6 +402,7 @@ class Address:
#----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_updates(self):
# 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
@ -516,6 +520,7 @@ class Address:
#----------------------------------------------------------------------
@test_engine.test_undo
def test_table_rename(self):
# 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):
# 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):
# Verify that changing a summary formula affects all group-by variants, and adding a new
# summary table gets the changed formula.
@ -706,6 +713,7 @@ class Address:
])
#----------------------------------------------------------------------
@test_engine.test_undo
def test_convert_source_column(self):
# 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.

@ -19,6 +19,7 @@ class TestSummary2(test_engine.EngineTestCase):
starting_table_data = test_summary.TestSummary.starting_table_data
@test_engine.test_undo
def test_add_summary_formula(self):
# 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
@ -162,6 +163,7 @@ class TestSummary2(test_engine.EngineTestCase):
#----------------------------------------------------------------------
@test_engine.test_undo
def test_summary_col_rename(self):
# 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.
@ -328,6 +330,7 @@ class TestSummary2(test_engine.EngineTestCase):
[21, 'foo3', True, 'WidgetOptions2'],
], rows=lambda r: r.colId in ('foo2', 'foo3'))
@test_engine.test_undo
def test_summary_col_rename_conflict(self):
sample = testutil.parse_test_sample({
"SCHEMA": [
@ -418,6 +421,7 @@ class TestSummary2(test_engine.EngineTestCase):
tables = [table1, fake_summary, summary_by_a_and_b, summary_by_a]
self.assertTables(tables)
@test_engine.test_undo
def test_source_table_rename_conflict(self):
sample = testutil.parse_test_sample({
"SCHEMA": [
@ -469,6 +473,7 @@ class TestSummary2(test_engine.EngineTestCase):
#----------------------------------------------------------------------
@test_engine.test_undo
def test_restrictions(self):
# Verify various restrictions on summary tables
# (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):
# Verify that we can change the group-by for a view section, and that unused tables get
# removed.
@ -876,6 +882,7 @@ class TestSummary2(test_engine.EngineTestCase):
#----------------------------------------------------------------------
@test_engine.test_undo
def test_update_groupby_override(self):
# 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):
# 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):
# 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):
# 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.

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

Loading…
Cancel
Save