Skip to content

Commit

Permalink
Fix search-api tests and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Reillyhewitson committed Feb 10, 2023
1 parent 1ef9eb2 commit d28919e
Show file tree
Hide file tree
Showing 9 changed files with 563 additions and 1,712 deletions.
62 changes: 33 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 19 additions & 6 deletions test/datagateway_api/db/test_database_filter_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def test_invalid_get_field(self, flask_test_app_db):
"name": "INVESTIGATION 1",
"releaseDate": "2000-07-05 00:00:00",
"startDate": "2000-04-03 00:00:00",
"summary": "Throw hope parent. Receive entire soon. War top air agent must voice high describe.\nMonth shake voice. Do discuss despite least face again study. Two beyond picture rich fast sea time.",
"summary": "Throw hope parent. Receive entire soon."
" War top air agent must voice high describe.\nMonth "
"shake voice. Do discuss despite least face again study."
" Two beyond picture rich fast sea time.",
"title": "Analysis reflect work or hour color maybe."
"\nMuch team discussion message weight.",
"facilityID": 1,
Expand Down Expand Up @@ -202,7 +205,10 @@ def test_invalid_get_field(self, flask_test_app_db):
"name": "INVESTIGATION 1",
"releaseDate": "2000-07-05 00:00:00",
"startDate": "2000-04-03 00:00:00",
"summary": "Throw hope parent. Receive entire soon. War top air agent must voice high describe.\nMonth shake voice. Do discuss despite least face again study. Two beyond picture rich fast sea time.",
"summary": "Throw hope parent. Receive entire soon. "
"War top air agent must voice high describe.\nMonth "
"shake voice. Do discuss despite least face again study. "
"Two beyond picture rich fast sea time.",
"title": "Analysis reflect work or hour color maybe."
"\nMuch team discussion message weight.",
"facilityID": 1,
Expand Down Expand Up @@ -267,8 +273,11 @@ def test_invalid_get_field(self, flask_test_app_db):
"name": "INVESTIGATION 29",
"releaseDate": "2007-07-05 00:00:00",
"startDate": "2007-04-03 00:00:00",
"summary": "City plant especially ever eight. Wife street under. Life character drive down. Bag sport benefit also price.\nIncrease spring box successful travel.",
"title": "Usually water six learn bring white development political. Meeting those voice hand.",
"summary": "City plant especially ever eight. Wife street"
" under. Life character drive down. Bag sport benefit also"
" price.\nIncrease spring box successful travel.",
"title": "Usually water six learn bring white development "
"political. Meeting those voice hand.",
"facilityID": 1,
"typeID": 1,
"fileSize": 0,
Expand All @@ -285,8 +294,12 @@ def test_invalid_get_field(self, flask_test_app_db):
"name": "INVESTIGATION 29",
"releaseDate": "2007-07-05 00:00:00",
"startDate": "2007-04-03 00:00:00",
"summary": "City plant especially ever eight. Wife street under. Life character drive down. Bag sport benefit also price.\nIncrease spring box successful travel.",
"title": "Usually water six learn bring white development political. Meeting those voice hand.",
"summary": "City plant especially ever eight. "
"Wife street under. Life character drive down. Bag sport"
" benefit also price.\nIncrease spring box successful"
" travel.",
"title": "Usually water six learn bring white development "
"political. Meeting those voice hand.",
"facilityID": 1,
"typeID": 1,
"fileSize": 0,
Expand Down
1 change: 1 addition & 0 deletions test/datagateway_api/icat/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from icat.entity import Entity
import pytest

from datagateway_api.src.common.date_handler import DateHandler
from datagateway_api.src.common.exceptions import PythonICATError
from datagateway_api.src.datagateway_api.icat.filters import (
Expand Down
22 changes: 11 additions & 11 deletions test/search_api/endpoints/test_count_dataset_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ class TestSearchAPICountDatasetFilesEndpoint:
"pid, request_filter, expected_json",
[
pytest.param(
"0-8401-1070-7",
"1-4978-6907-2",
"{}",
{"count": 56},
{"count": 15},
id="Basic /datasets/{pid}/files/count request",
# Skipped because empty dict for filter doesn't work on where
marks=pytest.mark.skip,
),
pytest.param(
"0-8401-1070-7",
'{"name": "Datafile 10060"}',
"1-4978-6907-2",
'{"name": "Datafile 1547"}',
{"count": 1},
id="Count dataset files with name condition",
),
pytest.param(
"0-8401-1070-7",
'{"name": {"nlike": "Datafile 10060"}}',
{"count": 55},
"1-4978-6907-2",
'{"name": {"nlike": "Datafile 9"}}',
{"count": 14},
id="Count dataset files with name condition (operator specified)",
),
pytest.param(
"0-8401-1070-7",
'{"size": {"gt": 50000000}}',
{"count": 40},
"1-4978-6907-2",
'{"size": {"gt": 500}}',
{"count": 15},
id="Count dataset files with size condition",
),
pytest.param(
"0-8401-1070-7",
"1-4978-6907-2",
'{"name": "Unknown Datafile"}',
{"count": 0},
id="Count dataset files with filter to return zero count",
Expand Down
8 changes: 4 additions & 4 deletions test/search_api/endpoints/test_count_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class TestSearchAPICountEndpoint:
),
pytest.param(
"datasets",
'{"title": {"like": "DATASET 30"}}',
'{"title": {"like": "DATASET 3"}}',
{"count": 11},
id="Dataset count with where (operator specified)",
),
pytest.param(
"documents",
'{"summary": {"ilike": "nature"}}',
{"count": 7},
{"count": 1},
id="Document count with where (operator specified)",
),
pytest.param(
Expand Down Expand Up @@ -92,13 +92,13 @@ def test_valid_count_endpoint(
pytest.param(
"datasets",
'{"isPublic": true}',
{"count": 479},
{"count": 119},
id="Dataset count with isPublic condition (True)",
),
pytest.param(
"documents",
'{"isPublic": true}',
{"count": 239},
{"count": 59},
id="Document count with isPublic condition (True)",
),
pytest.param(
Expand Down
Loading

0 comments on commit d28919e

Please sign in to comment.