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

Update tests and remove unused code #18

Merged
merged 5 commits into from
Jun 25, 2024
Merged

Update tests and remove unused code #18

merged 5 commits into from
Jun 25, 2024

Conversation

rosswhitfield
Copy link
Member

@rosswhitfield rosswhitfield commented Jun 25, 2024

Ref 5462: LiveDataServer: Enhance (Add) Tests

This adds tests to cover all the endpoints used.

I removed the endpoint /plots/$instrument/$run_number/ as it was not used by anything that I know of. It also included an old version of jquery with known vulnerabilities so nobody should be using it.

I also did a small amount of code improvements as I seen things.

Short description of the changes:

Long description of the changes:

Check list for the pull request

  • I have read the [CONTRIBUTING]
  • I have read the [CODE_OF_CONDUCT]
  • I have added tests for my changes
  • I have updated the documentation accordingly

Check list for the reviewer

  • I have read the [CONTRIBUTING]
  • I have verified the proposed changes
  • best software practices
    • all internal functions have an underbar, as is python standard
    • clearly named variables (better to be verbose in variable names)
    • code comments explaining the intent of code blocks
  • All the tests are passing
  • The documentation is up to date
  • code comments added when explaining intent

Manual test for the reviewer

References

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.95%. Comparing base (b329f66) to head (590c5a3).

Files Patch % Lines
src/live_data_server/plots/models.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             next      #18       +/-   ##
===========================================
+ Coverage   76.82%   86.95%   +10.13%     
===========================================
  Files          10       10               
  Lines         302      276       -26     
===========================================
+ Hits          232      240        +8     
+ Misses         70       36       -34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rosswhitfield rosswhitfield marked this pull request as ready for review June 25, 2024 01:36
Copy link
Collaborator

@backmari backmari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes some unused code and adds new tests covering uploading JSON data, requests for non-existing data, unauthorized requests and authorization within sessions. Looks good to me 👌

else:
raise PermissionDenied
return HttpResponse(status=401)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌


def test_session(self):
# once you authenicate once with username and password you should be able to reuse the session with credentials
session = requests.Session()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, I didn't know it worked with sessions

@rosswhitfield rosswhitfield merged commit c35a9ca into next Jun 25, 2024
4 checks passed
@rosswhitfield rosswhitfield deleted the update_tests branch June 25, 2024 21:52
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