Skip to content

Conversation

@vinisalazar
Copy link
Contributor

@vinisalazar vinisalazar commented Jun 20, 2022

Hi,

this is in relation to #244. I wasn't sure of the best way to go about this, so I tried keeping it as simple as possible. Please let me know if there's an obvious way that I'm missing.

What I did was simply to set the number of items_per_page to a big number (initially it was 1e9, but I thought that was excessive?) if the response is either 'csv' or 'json'. This doesn't require actually making the request, it just builds the URL. I couldn't find a "number of records" variable in the search response. I suppose I could set the items_per_page variable to that, but that would require making the request, and I understand that we just want the URL. Removing the items_per_page or page variables from the URL didn't make any difference.

To test, I added a fixture for the gliders server, since the other two had less than 1000 records. I did not commit the cassettes since they turned out fairly large, at around 3MB each. Do you have any suggestions on what to do about this?

Summary of changes

  • Modify variable items_per_page if response is either 'csv' or 'json'
  • Add new fixture gliders to test_to_objects.py
  • Add tests test_csv_search and test_json_search

Please feel free to request any changes, and don't forget to add the gsoc-2022 label :)

Thank you,
Vini

…s#244)

  - Set items_per_page variable to 1e6 if response is either csv or json
  - Add new fixture 'gliders' - has more than 1000 datasets
  - Adds tests 'test_csv_search' and 'test_json_search' that check if the response
  has more than 1000 records
@vinisalazar
Copy link
Contributor Author

I think that the test failing here may be fixed by #253.

@abkfenris
Copy link
Contributor

While you could write a mock response generator, you then would be testing that more so than .get_search_url().

In this case, I think we can skip calling the endpoints, and instead inspect the URL returned from .get_search_url() directly to make sure that it is the formatting differently based on the response type.

Additionally we could leave these tests in in addition to testing the URL, mark them, and have pytest skip them by default. Then maybe we set up a weekly cron driven actions workflow to run those tests and update the VCR cassettes to do a fuller test run?

@vinisalazar
Copy link
Contributor Author

Hi @abkfenris, sounds good to me, I'll add new tests that check the URL. However, I'm still thinking we should drop the test on the CoastWatch server? That seems to be behaving inconsistently. Please let me know what you think works best.

Thanks,
Vini

@abkfenris
Copy link
Contributor

Ya, avoiding the Coastwatxh server might be best with Bobs aggressive blocklist.

@vinisalazar
Copy link
Contributor Author

Do you think you could merge #253 then? Please let me know if you'd like me to make any changes to that.

Thanks,
Vini

  - On method ERDDAP.get_search_url, add all CSV, JSON and TSV-type responses to variable 'non_paginated_responses'
@ocefpaf
Copy link
Member

ocefpaf commented Jul 28, 2022

@vinisalazar do you mind rebasing this one to fix the conflict?

Please let me know if you need help with that!

…s#244)

  - Set items_per_page variable to 1e6 if response is either csv or json
  - Add new fixture 'gliders' - has more than 1000 datasets
  - Adds tests 'test_csv_search' and 'test_json_search' that check if the response
  has more than 1000 records
  - On method ERDDAP.get_search_url, add all CSV, JSON and TSV-type responses to variable 'non_paginated_responses'
@vinisalazar
Copy link
Contributor Author

@ocefpaf I had a go at doing it, not sure if I got it right. I can reset the branch and redo it if needed.

@vinisalazar
Copy link
Contributor Author

I'll definitely accept the offer for helping out with this one!

@ocefpaf
Copy link
Member

ocefpaf commented Jul 28, 2022

Looks like you got it. At least the original changes are in there, only one tests is failing.

  - Improve comment in function 'get_search_url'
  - Move duplicated comment to fixture 'gliders'
@vinisalazar
Copy link
Contributor Author

Thank you for the review @ocefpaf!

@ocefpaf ocefpaf merged commit b6a1f7e into ioos:main Jul 28, 2022
@ocefpaf ocefpaf added the GSoC22 label Jul 28, 2022
@vinisalazar vinisalazar deleted the issue-244 branch August 31, 2022 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants