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

TestURLs coverage for (most of) console #2108

Merged
merged 2 commits into from
Oct 16, 2023
Merged

TestURLs coverage for (most of) console #2108

merged 2 commits into from
Oct 16, 2023

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented Oct 12, 2023

This adds test coverage for most of the URLs in the console app.

(See pull #1695 for an overview of how URL testing works.)

A few URLs can't be tested and some of these test cases aren't really meaningful, but overall this adds a fair amount of coverage. I want to do this because the console templates could use a lot of improvement.

Making an exhaustive list also helps to highlight some of the poor logic that I wasn't aware of. Look at these lovely warnings, pointing out that the code is doing something it shouldn't:

/home/benjamin/physionet-build3/physionet-django/physionet/utility.py:329: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'project.modelcomponents.publishedproject.PublishedProject'> QuerySet.
  paginator = Paginator(to_paginate, maximum)
/home/benjamin/physionet-build3/physionet-django/physionet/utility.py:329: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'user.models.User'> QuerySet.
  paginator = Paginator(to_paginate, maximum)
/home/benjamin/physionet-build3/physionet-django/physionet/utility.py:329: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'project.modelcomponents.activeproject.ActiveProject'> QuerySet.
  paginator = Paginator(to_paginate, maximum)
/home/benjamin/ve-pndjangoplus/lib/python3.9/site-packages/django/views/generic/list.py:91: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'user.models.User'> QuerySet.
  return self.paginator_class(
/home/benjamin/ve-pndjangoplus/lib/python3.9/site-packages/django/views/generic/list.py:91: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'project.modelcomponents.publishedproject.PublishedProject'> QuerySet.
  return self.paginator_class(
/home/benjamin/physionet-build3/physionet-django/physionet/utility.py:329: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'events.models.Event'> QuerySet.
  paginator = Paginator(to_paginate, maximum)

(Oh, and I fixed a bug in the credentialing stats.)

Benjamin Moody added 2 commits October 12, 2023 16:06
If applications have been submitted during a particular year, but no
applications from that year have (yet) been accepted or rejected, then
it is impossible to compute the percentage of accepted applications
(since pending and withdrawn applications aren't counted.)

(For example, the demo data currently includes a pending application
from year 2022, but no accepted or rejected applications.)

Set this value to None, as is done with other metrics that cannot be
computed.
A few URLs in this app cannot currently be tested due to a lack of
demo data; in particular, testing the project submission pipeline
would require creating a demo project for each submission stage.

Many URLs in this app use a parameter called, uninformatively, "pk".
In most such cases, setting "pk" to 1 will work; but it'd be wiser to
use a descriptive name for the parameter.  It'd also be wiser not to
use integer IDs in URLs to begin with, and it would be wiser not to
assume that integer IDs are also primary keys.

Also note that user_access_logs_detail misleadingly names its
parameter "pid" (it's a user ID, not any kind of project ID.)
@tompollard
Copy link
Member

thanks!

@tompollard tompollard merged commit a7822f1 into dev Oct 16, 2023
@tompollard tompollard deleted the console-testurls branch October 16, 2023 14:45
tompollard added a commit that referenced this pull request May 14, 2024
This adds test coverage for most of the URLs in the `project` app.

See the previous pull requests #1695, #1922, #2108 for background.

With this change, the bulk of site functionality should now be included
in the TestURLs framework. A few small apps are left to add:
- `oauth` (should be easy)
- `sso` (should be easy but I'm not sure this is enabled in test
configs)
- `training` (awaiting pull #1951)

And a number of URLs across the site are skipped due to a lack of
fixture data:
- `console`
  - `edit_submission`
  - `copyedit_submission`
  - `awaiting_authors`
  - `publish_submission`
  - `event_agreement_detail`
  - `event_agreement_delete`
  - `event_agreement_new_version`
- `project`
  - `serve_document`
  - `published_project_request_access`
- `search`
  - `redirect_challenge_project`
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.

2 participants