Skip to content

Commit

Permalink
Fix display options test cases due to merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
silentninja committed May 31, 2022
1 parent 24ef4be commit f828dd9
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions mathesar/tests/api/test_column_api_display_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def column_test_table_with_service_layer_options(patent_schema):
]
column_data_list = [
{},
{'display_options': {'input': "dropdown", "custom_labels": {"TRUE": "yes", "FALSE": "no"}}},
{'display_options': {'show_as_percentage': True, 'number_format': "english"}},
{'display_options': {'input': "dropdown", "custom_labels": {"TRUE": "yes", "FALSE": "no"}}, 'show_fk_preview': True},
{'display_options': {'show_as_percentage': True, 'number_format': "english", 'show_fk_preview': True}},
{'display_options': None},
{},
{
Expand All @@ -37,12 +37,13 @@ def column_test_table_with_service_layer_options(patent_schema):
'currency_symbol': "HK $",
'number_format': "english",
'currency_symbol_location': 'after-minus'
}
},
'show_fk_preview': True
}
},
{'display_options': {'time_format': 'hh:mm', 'date_format': 'YYYY-MM-DD'}},
{'display_options': {'format': 'hh:mm'}},
{'display_options': {'format': 'YYYY-MM-DD'}},
{'display_options': {'time_format': 'hh:mm', 'date_format': 'YYYY-MM-DD', 'show_fk_preview': True}},
{'display_options': {'format': 'hh:mm', 'show_fk_preview': True}},
{'display_options': {'format': 'YYYY-MM-DD', 'show_fk_preview': True}},
]
db_table = SATable(
"anewtable",
Expand Down Expand Up @@ -71,57 +72,57 @@ def column_test_table_with_service_layer_options(patent_schema):
(
PostgresType.BOOLEAN,
{"input": "dropdown"},
{"input": "dropdown"}
{"input": "dropdown", 'show_fk_preview': True}
),
(
PostgresType.BOOLEAN,
{"input": "checkbox", "custom_labels": {"TRUE": "yes", "FALSE": "no"}},
{"input": "checkbox", "custom_labels": {"TRUE": "yes", "FALSE": "no"}}
{"input": "checkbox", "custom_labels": {"TRUE": "yes", "FALSE": "no"}, 'show_fk_preview': True}
),
(
PostgresType.DATE,
{'format': 'YYYY-MM-DD'},
{'format': 'YYYY-MM-DD'}
{'format': 'YYYY-MM-DD', 'show_fk_preview': True}
),
(
PostgresType.INTERVAL,
{'min': 's', 'max': 'h', 'show_units': True},
{'min': 's', 'max': 'h', 'show_units': True}
{'min': 's', 'max': 'h', 'show_units': True, 'show_fk_preview': True}
),
(
PostgresType.MONEY,
{'number_format': "english", 'currency_symbol': '$', 'currency_symbol_location': 'after-minus'},
{'currency_symbol': '$', 'currency_symbol_location': 'after-minus', 'number_format': "english"}
{'currency_symbol': '$', 'currency_symbol_location': 'after-minus', 'number_format': "english", 'show_fk_preview': True}
),
(
PostgresType.NUMERIC,
{"show_as_percentage": True, 'number_format': None},
{"show_as_percentage": True, 'number_format': None}
{"show_as_percentage": True, 'number_format': None, 'show_fk_preview': True}
),
(
PostgresType.NUMERIC,
{"show_as_percentage": True, 'number_format': "english"},
{"show_as_percentage": True, 'number_format': "english"}
{"show_as_percentage": True, 'number_format': "english", 'show_fk_preview': True}
),
(
PostgresType.TIMESTAMP_WITH_TIME_ZONE,
{'date_format': 'x', 'time_format': 'x'},
{'date_format': 'x', 'time_format': 'x'}
{'date_format': 'x', 'time_format': 'x', 'show_fk_preview': True}
),
(
PostgresType.TIMESTAMP_WITHOUT_TIME_ZONE,
{'date_format': 'x', 'time_format': 'x'},
{'date_format': 'x', 'time_format': 'x'}
{'date_format': 'x', 'time_format': 'x', 'show_fk_preview': True}
),
(
PostgresType.TIME_WITHOUT_TIME_ZONE,
{'format': 'hh:mm'},
{'format': 'hh:mm'}
{'format': 'hh:mm', 'show_fk_preview': True}
),
(
PostgresType.TIME_WITH_TIME_ZONE,
{'format': 'hh:mm Z'},
{'format': 'hh:mm Z'}
{'format': 'hh:mm Z', 'show_fk_preview': True}
),
]

Expand Down Expand Up @@ -230,7 +231,8 @@ def test_column_update_display_options(column_test_table_with_service_layer_opti
column_id = column.id
display_options = {
"input": "dropdown",
"custom_labels": {"TRUE": "yes", "FALSE": "no"}
"custom_labels": {"TRUE": "yes", "FALSE": "no"},
'show_fk_preview': False
}
column_data = {
'type': PostgresType.BOOLEAN.id,
Expand Down Expand Up @@ -317,11 +319,11 @@ def test_column_alter_same_type_display_options(


@pytest.mark.parametrize(
"display_options,type_options",
[[None, None], [{}, {}]]
"display_options,type_options, expected_display_options, expected_type_options",
[[None, None, None, None], [{}, {}, {'show_fk_preview': True}, {}]]
)
def test_column_update_type_with_display_and_type_options_as_null_or_empty_obj(
column_test_table, client, display_options, type_options
column_test_table, client, display_options, type_options, expected_display_options, expected_type_options
):
db_type_id = MathesarCustomType.URI.id
data = {
Expand All @@ -337,6 +339,6 @@ def test_column_update_type_with_display_and_type_options_as_null_or_empty_obj(
assert response.status_code == 200
response_json = response.json()
assert response_json["type"] == db_type_id
assert response_json["display_options"] == display_options
assert response_json["display_options"] == expected_display_options
# For some reason, type_options will reflect None, whether it was updated to None or to {}.
assert response_json["type_options"] is None

0 comments on commit f828dd9

Please sign in to comment.