Skip to content

Commit 65a56dc

Browse files
committed
Multiple column header depencies test
1 parent aa79935 commit 65a56dc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

mitosheet/mitosheet/tests/step_performers/column_steps/test_set_column_formula.py

+8
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,14 @@ def test_set_specific_index_labels_to_header_header():
542542

543543
assert mito.dfs[0].equals(pd.DataFrame({'A': [1, 2, 3], 'B': [6, 0, 0]}))
544544

545+
546+
def test_set_specific_index_labels_to_header_header_multiple_header_dependencies():
547+
mito = create_mito_wrapper(pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}))
548+
mito.add_column(0, 'C')
549+
mito.set_formula('=SUM(A:B)', 0, 'C', index_labels=[0])
550+
551+
assert mito.dfs[0].equals(pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [21, 0, 0]}))
552+
545553
CROSS_SHEET_TESTS = [
546554
(
547555
pd.DataFrame({'A': [1, 2, 3]}),

mitosheet/mitosheet/tests/test_parse.py

+16
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,22 @@ def test_specific_index_labels_header_header():
12901290
columns
12911291
)
12921292

1293+
def test_specific_index_labels_header_header_multiple_header_dependencies():
1294+
formula = '=SUM(A:B)'
1295+
column_header = 'C'
1296+
formula_label = 0
1297+
df = pd.DataFrame(get_number_data_for_df(['A', 'B', 'C'], 2), index=pd.RangeIndex(0, 2))
1298+
python_code = 'df.loc[[0], [\'C\']] = SUM(df.loc[:, \'A\':\'B\'])'
1299+
functions = set(['SUM'])
1300+
columns = set(['A', 'B'])
1301+
code, funcs, cols, _ = parse_formula(formula, column_header, formula_label, {'type': FORMULA_SPECIFIC_INDEX_LABELS_TYPE, 'index_labels': [0]}, [df], ['df'], 0)
1302+
assert (code, funcs, cols) == \
1303+
(
1304+
python_code,
1305+
functions,
1306+
columns
1307+
)
1308+
12931309
@pytest.mark.parametrize("formula,column_header,formula_label,dfs,df_names,sheet_index,python_code,functions,columns", POST_PD_1_2_VLOOKUP_TESTS)
12941310
@pandas_post_1_2_only
12951311
def post_pandas_1_2_cross_sheet_tests(formula,column_header,formula_label,dfs,df_names,sheet_index,python_code,functions,columns):

0 commit comments

Comments
 (0)