Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Missing Endpoint Tests & Fix parameters.value bug #342

Merged
merged 2 commits into from
Feb 28, 2022

Conversation

MRichards99
Copy link
Collaborator

This PR will close #270

Description

This PR adds endpoint tests to match the example queries given in the example implementation of the search API. The linked issue shows which tests were missing, and below shows a list of those query names alongside the corresponding Pytest parameter names which I've added:

  • Query datasets acquired using X-Ray Absorption - Search datasets with condition on techniques name (ICAT 5)
  • Query datasets where the photon energy range is 880-990 eV - Search datasets with parameters include and conditions (between operator, A AND B AND C)
  • Query datasets with a solid sample or copper - Search datasets with parameters include and conditions ((A AND B) OR (C AND D)
  • Query datasets where temperature is below 80°C - Search datasets with parameters include and conditions (lt operator, A AND B AND C)
  • Query datasets with files matching a string using full text search - Search datasets' files using full text search
  • Query documents of type proposal containing my own data - Search documents with document condition, multiple includes (nested) and conditions on those with parameters include and conditions
  • Query documents where wavelength is 1000-1100 nm - Search documents with parameters include and conditions (between operator, A AND B AND C)
  • Query documents containing datasets where wavelength is 1000-1100 nm - Search documents with datasets.parameters include and conditions (between operator, A AND B AND C)
  • Query documents investigating a particular sample using a certain technique - Search documents with multiple include and scopes (ICAT 5)

Two of the example queries are reliant on ICAT 5 - I've added these tests and added skips to them until ICAT 5 exists. In #310, we should unskip these tests. I've made a best attempt at writing the query parameters and the test data for those tests, but small adjustments will probably need to be made (e.g. when we know what the techniques test data will look like).

Whilst writing these tests, I came across a bug when a request contains a WHERE filter with a between operator on parameters.value. Query datasets where the photon energy range is 880-990 eV is an example where this bug would occur. This has been fixed in 3fe8dfe by detecting this use case and checking the type of the first value in the list (e.g. between [20, 30]). I added a test in test_search_api_where_filter.py to test this at the WHERE filter level; the endpoint tests added in this PR also test this at an endpoint level.

A fix version bump will be applied when merging this PR (print-version command currently says 4.1.2).

Testing Instructions

Test the parameters.value between operator has been fixed

  • Review code
  • Check GitHub Actions build
  • If icatdb Generator Script Consistency Test CI job fails, is this because of a deliberate change made to the script to change generated data (which isn't actually a problem) or is here an underlying issue with the changes made?
  • Review changes to test coverage
  • Does this change mean a new patch, minor or major version should be made? If so, does one of the commit messages feature fix:, feat: or BREAKING CHANGE: so a release is automatically made via GitHub Actions upon merge?
  • Additional tests should cover all the example queries in the example implementation of the search API
  • A request with a WHERE filter on parameters.value that uses a between operator should return a 200 with relevant data

Agile Board Tracking

Connect to #270

@MRichards99 MRichards99 requested a review from VKTB February 24, 2022 13:39
@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #342 (2c21bab) into master (598bf9f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #342   +/-   ##
=======================================
  Coverage   94.46%   94.46%           
=======================================
  Files          39       39           
  Lines        3070     3073    +3     
  Branches      306      307    +1     
=======================================
+ Hits         2900     2903    +3     
  Misses        144      144           
  Partials       26       26           
Impacted Files Coverage Δ
datagateway_api/src/search_api/filters.py 98.83% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 598bf9f...2c21bab. Read the comment docs.

Base automatically changed from bugfix/including-parameters-#319 to master February 28, 2022 10:23
@MRichards99 MRichards99 merged commit 6d5edf5 into master Feb 28, 2022
@MRichards99 MRichards99 deleted the example-query-tests-#270 branch February 28, 2022 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write Tests to Cover Example Queries
2 participants