Skip to content

Add test coverage to ensure that SQL tracker wrappers are applied only once to database cursors #1478

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

Merged
merged 4 commits into from
Jul 20, 2021
Merged

Add test coverage to ensure that SQL tracker wrappers are applied only once to database cursors #1478

merged 4 commits into from
Jul 20, 2021

Conversation

jayaddison
Copy link
Contributor

This is an attempt to add test coverage for the behaviour discovered in #1239 and addressed in #1475.

The idea is to patch the state.Wrapper method that is called to add each wrapping layer, and count the number of calls for both chunked and non-chunked types of cursor (across all database provider implementations).

cc @saemideluxe

This was referenced Jun 19, 2021
@tim-schilling
Copy link
Member

tim-schilling commented Jun 21, 2021

Thanks for this @jayaddison. Did you happen to run these tests before 1475 was merged to verify that this would catch the duplicates?

@jayaddison
Copy link
Contributor Author

@tim-schilling Although I only learned about the problem after a fix had been found (always nice to learn that a bug has already been solved), yep I did run this test coverage on a version of the code without the fix in place, to make sure that it failed before-the-fix and passes after-the-fix (albeit a small modification required, in honesty partly due to issues encountered with Python mock/patching.. see #1479).

@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

Merging #1478 (ca93f67) into main (77bbc8a) will increase coverage by 0.10%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1478      +/-   ##
==========================================
+ Coverage   86.27%   86.38%   +0.10%     
==========================================
  Files          35       35              
  Lines        1858     1858              
  Branches      261      261              
==========================================
+ Hits         1603     1605       +2     
+ Misses        182      181       -1     
+ Partials       73       72       -1     
Impacted Files Coverage Δ
debug_toolbar/panels/profiling.py 88.39% <0.00%> (+1.78%) ⬆️

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 77bbc8a...ca93f67. Read the comment docs.

@matthiask matthiask merged commit 085f8dd into django-commons:main Jul 20, 2021
@jayaddison jayaddison deleted the test-coverage/sql-panel-cursor-wrapping branch July 20, 2021 21:03
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.

3 participants