Skip to content

Commit

Permalink
Merge pull request #6397 from knabar/table-api-tests
Browse files Browse the repository at this point in the history
Tests for get_where_list and slice table API calls
  • Loading branch information
jburel authored Jul 29, 2024
2 parents cf32e73 + 5f274d9 commit 1e05296
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions components/tools/OmeroWeb/test/integration/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,71 @@ def test_table_metadata(self, omero_table_file, django_client, table_data):

assert rsp['user_metadata']['test'] == 'value'
assert rsp['user_metadata']['my_number'] == 100

@pytest.mark.parametrize("query_result", [
['query=Well>2', [2, 3, 4], 0],
['query=Well>2&start=3', [3, 4], 3],
])
def test_table_get_where_list(
self, omero_table_file, django_client, table_data, query_result):
"""
Test query call returning resulting row numbers
"""
col_types, col_names, rows = table_data
query, expected, start = query_result
request_url = reverse("webgateway_table_get_where_list",
args=[omero_table_file])
response = get_json(django_client, '%s?%s' % (request_url, query))
assert response['rows'] == expected
assert response['meta']['partialCount'] == len(expected)
assert response['meta']['rowCount'] == 5
assert response['meta']['columnCount'] == len(col_types)
assert response['meta']['start'] == start
assert response['meta']['end'] == len(rows)
assert response['meta']['maxCells'] > 0

@pytest.mark.parametrize("query_result", [
['rows=0-4&columns=0', [[1, 2, 3, 4, 5]], ['Well']],
['rows=0&columns=0,1', [[1], ['test']], ['Well', 'TestColumn']],
['rows=0,1&columns=0-1', [[1, 2], ['test', 'string']],
['Well', 'TestColumn']],
])
def test_table_perform_slice(
self, omero_table_file, django_client, table_data, query_result):
"""
Test slice call returning table data in columnar format
"""
col_types, col_names, rows = table_data
query, result, columns = query_result
request_url = reverse("webgateway_table_slice",
args=[omero_table_file])
response = get_json(django_client, '%s?%s' % (request_url, query))
assert response['columns'] == result
assert response['meta']['columns'] == columns
assert response['meta']['rowCount'] == len(rows)
assert response['meta']['columnCount'] == len(col_types)
assert response['meta']['maxCells'] > 0

@pytest.mark.parametrize("query_validity", [
['', False], # missing rows and columns
['rows=0-4', False], # missing columns
['columns=0-2', False], # missing rows
['rows=0-4&columns=0-100', False], # columns out of range
['rows=0-1000000&columns=0-4', False], # too many cells
['rows=0-100&columns=0-4', False], # rows out of range
['rows=0-3,-1&columns=0-4', False], # invalid row
['rows=0,2.5&columns=0-4', False], # invalid row
['rows=0,X-Y&columns=0-4', False], # invalid row
['rows=0-3&columns=0-4', True], # all good
])
def test_table_perform_slice_errors(
self, omero_table_file, django_client, table_data,
query_validity):
"""
Test invalid slice calls
"""
query, valid = query_validity
request_url = reverse("webgateway_table_slice",
args=[omero_table_file])
response = get_json(django_client, '%s?%s' % (request_url, query))
assert ('error' not in response) == valid

0 comments on commit 1e05296

Please sign in to comment.