Skip to content

Commit

Permalink
Update record api grouping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eito-fis committed Jul 12, 2021
1 parent 662b99d commit 8db68c4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions mathesar/tests/views/api/test_record_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ def test_record_list_sort(create_table, client):


def _test_record_list_group(table, client, group_count_by, expected_groups):
order_by = [
{'field': 'Center', 'direction': 'desc'},
{'field': 'Case Number', 'direction': 'asc'},
]
json_order_by = json.dumps(order_by)
json_group_count_by = json.dumps(group_count_by)
query_str = f'group_count_by={json_group_count_by}&order_by={json_order_by}'

with patch.object(
records, "get_group_counts", side_effect=records.get_group_counts
) as mock_infer:
response = client.get(
f'/api/v0/tables/{table.id}/records/?group_count_by={json_group_count_by}'
)
response = client.get(f'/api/v0/tables/{table.id}/records/?{query_str}')
response_data = response.json()

assert response.status_code == 200
Expand All @@ -147,8 +151,8 @@ def test_record_list_group_single_column(create_table, client):
table = create_table(table_name)
group_count_by = ['Center']
expected_groups = [
'NASA Ames Research Center',
'NASA Kennedy Space Center'
'NASA Marshall Space Flight Center',
'NASA Stennis Space Center'
]
_test_record_list_group(table, client, group_count_by, expected_groups)

Expand All @@ -158,8 +162,8 @@ def test_record_list_group_multi_column(create_table, client):
table = create_table(table_name)
group_count_by = ['Center', 'Status']
expected_groups = [
'NASA Ames Research Center,Issued',
'NASA Kennedy Space Center,Issued',
'NASA Marshall Space Flight Center,Issued',
'NASA Stennis Space Center,Issued',
]
_test_record_list_group(table, client, group_count_by, expected_groups)

Expand Down

0 comments on commit 8db68c4

Please sign in to comment.