-
Notifications
You must be signed in to change notification settings - Fork 24
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 some search tests to check some fulltext searches #676
base: testing
Are you sure you want to change the base?
Conversation
The tests just check that the correct number of results are returned. If there's someething wrong with the fulltext searches, it should cause an issue with at least one of these tests. I'm not sure if this is the right place to put these tests, so they might need to be moved somewhere else later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for testing, try to have these tests pass on your own local set-up. Then, add then try to capture the tests that were failing. Happy Hacking!
found = result.text.find(this_search["found_text"]) | ||
assert(found >= 0) | ||
assert(result.status_code == 200) | ||
print("OK") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: No need for this statement.
] | ||
|
||
def check_fulltext_searches(host): | ||
for this_search in searches: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Try (same case for me) to be more mindful of naming. this_search
can be off. How about:
for this_search in searches: | |
for search in searches: | |
How exactly do I go about doing a test like this? I more or less understand
how to run unit tests (and have existing examples of those to look at), but
I'm not sure how to run this kind of test (the only examples I could find
are the ones in the directory I mentioned in the other email, which as you
mentioned I think depended on Mechanical Rob).
…On Wed, Mar 2, 2022 at 10:43 AM BonfaceKilz ***@***.***> wrote:
***@***.**** commented on this pull request.
Also for testing, try to have these tests pass on your own local set-up.
Then, add then try to capture the tests that were failing. Happy Hacking!
------------------------------
In test/requests/search_tests.py
<#676 (comment)>
:
> + "group": "BXD",
+ "type": "Hippocampus mRNA",
+ "dataset": "HC_M2_0606_P",
+ "search_terms_or": "sh*",
+ "search_terms_and": ""
+ }
+ }
+]
+
+def check_fulltext_searches(host):
+ for this_search in searches:
+ result = requests.get(host+"/search", params=this_search["data"])
+ found = result.text.find(this_search["found_text"])
+ assert(found >= 0)
+ assert(result.status_code == 200)
+ print("OK")
*nitpick*: No need for this statement.
------------------------------
In test/requests/search_tests.py
<#676 (comment)>
:
> + },
+ {
+ "found_text": "1017 records were found",
+ "data": {
+ "species": "mouse",
+ "group": "BXD",
+ "type": "Hippocampus mRNA",
+ "dataset": "HC_M2_0606_P",
+ "search_terms_or": "sh*",
+ "search_terms_and": ""
+ }
+ }
+]
+
+def check_fulltext_searches(host):
+ for this_search in searches:
*nitpick*: Try (same case for me) to be more mindful of naming.
this_search can be off. How about:
⬇️ Suggested change
- for this_search in searches:
+ for search in searches:
—
Reply to this email directly, view it on GitHub
<#676 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANQJGBJGILRW5O7EMLUY2TU56LDDANCNFSM5PVGOMWA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
zsloan ***@***.***> anaandika:
How exactly do I go about doing a test like this? I more or less understand
how to run unit tests (and have existing examples of those to look at), but
I'm not sure how to run this kind of test (the only examples I could find
are the ones in the directory I mentioned in the other email, which as you
mentioned I think depended on Mechanical Rob).
Can you run Mechanical Rob? If not, then we need
to make that clear for both you and the rest of
the team. That's on my plate. Also, in addition to
running Mechanical Rob, you could inspect the
underlying functions in that global search and
test for those. Some tests could be to check that
the right SQL query is being run; or that the
processing of results from said query is done
properly. That said, in gn2 some functions are
notoriously difficult to test, so don't spend too
much time on that. Also, I've found that using
pudb for class, function and variable
introspection has been really useful in both
troubleshooting and working out how to test. When
we meet together, I could briefly show you how to
use that.
|
Not sure how to actually make this test work with the CI, or whether
it's even in the right place.
Currently, the CI will run all tests run by the following command. You
don't have to do anything special to get it into the CI.
```
./bin/genenetwork2 /etc/default_settings.py -c -m unittest -v
```
End-to-end tests with Mechanical Rob are not yet implemented in the
CI. I am in conversation with Bonface about that.
|
04f10df
to
5474e66
Compare
This PR adds some search tests, mainly to ensure that the fulltext searches continue to work the same way. It only checks for the correct number of results, but that should be sufficient if done across multiple possible searches.
Not sure how to actually make this test work with the CI, or whether it's even in the right place.