Skip to content

Changing query filters from list of tuples to dict - #37

Merged
frgfm merged 25 commits into
pyronear:masterfrom
martin1tab:Issue28
Nov 21, 2020
Merged

frgfm merged 25 commits into
pyronear:masterfrom
martin1tab:Issue28

Conversation

@martin1tab

Copy link
Copy Markdown
Collaborator

Issue28's description:

While designing new unittests, I figured I wasn't sure about what to expect when we use query_filters with multiple filters on a single value. Since this does not include order relationships but strictly equality, I suggest changing this to a dictionary to prevent duplication of keys.

Here is an example on the fetch_all crud function:

what a call currently looks like

result_entries = crud.fetch_all(user_table, [('username', 'fg')]
my suggestion

result_entries = crud.fetch_all(user_table, {'username': 'fg'}]

@martin1tab martin1tab changed the title Issue28 Enhancement Nov 15, 2020
@codecov

codecov Bot commented Nov 15, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #37 (9192c4d) into master (b575d96) will increase coverage by 1.09%.
The diff coverage is 61.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage   87.38%   88.48%   +1.09%     
==========================================
  Files          19       19              
  Lines         547      547              
==========================================
+ Hits          478      484       +6     
+ Misses         69       63       -6     
Flag Coverage Δ
unittests 88.48% <61.53%> (+1.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/app/api/crud.py 61.36% <28.57%> (ø)
src/app/api/deps.py 48.71% <100.00%> (+15.38%) ⬆️
src/app/api/routes/accesses.py 85.29% <100.00%> (ø)
src/app/api/routes/devices.py 100.00% <100.00%> (ø)
src/app/api/routes/login.py 94.44% <100.00%> (ø)

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 b575d96...9192c4d. Read the comment docs.

@martin1tab martin1tab added the type: improvement New feature or request label Nov 15, 2020
@martin1tab martin1tab changed the title Enhancement Changing query filters from list of tuples to dict Nov 15, 2020
@frgfm

frgfm commented Nov 15, 2020

Copy link
Copy Markdown
Member

@martin1tab Thanks for the PR! We're just waiting for #33 to be merged, because it deletes the routing module. So there might be conflicts with your PR. But overall, your proposition looks good! Could you just investigate the low coverage on diff hit please? 🙏

@florianriche florianriche left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK for me beside a nitpicking comment.
The unit tests may need to be changed too because we are currently refactoring them.

As a side note, I am surprised that we don't have any other unit tests to adapt. It's probably a bad sign.

Comment thread src/app/api/crud.py Resolved
Comment thread src/tests/test_deps.py Outdated
import pytest

from app.api import crud
from app.api.deps import get_current_user, get_current_device

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You may look at the Unit test refactoring in #33 to stay in the same spirit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not done yet:
I agree; but I am struggling a little bit to monkey-patch the users and devices tables in this module (test_deps); but I will take this comment into account in my next PR

@frgfm frgfm added this to the 0.1.0 milestone Nov 17, 2020
@frgfm frgfm linked an issue Nov 17, 2020 that may be closed by this pull request
@frgfm

frgfm commented Nov 17, 2020

Copy link
Copy Markdown
Member

Hey @martin1tab,
Thanks for the PR!
Could you merge master into this before moving on to reviewing? 🙏

Comment thread src/app/api/deps.py Resolved
Comment thread src/app/api/deps.py Resolved
@martin1tab

Copy link
Copy Markdown
Collaborator Author

@martin1tab Thanks for the PR! We're just waiting for #33 to be merged, because it deletes the routing module. So there might be conflicts with your PR. But overall, your proposition looks good! Could you just investigate the low coverage on diff hit please? 🙏

Yes, I still have this issue; I am still investigating this problem

@martin1tab martin1tab closed this Nov 18, 2020
@martin1tab

martin1tab commented Nov 18, 2020 •

Copy link
Copy Markdown
Collaborator Author

@martin1tab Thanks for the PR! We're just waiting for #33 to be merged, because it deletes the routing module. So there might be conflicts with your PR. But overall, your proposition looks good! Could you just investigate the low coverage on diff hit please? 🙏

Yes, I still have this issue; I am still investigating this problem

I think that the coverage issue is due to never calling the functions crud.fetch_all and crud.fetch_one but always the mocked functions instead

@martin1tab martin1tab reopened this Nov 18, 2020

@frgfm frgfm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few things to adapt in the test but the rest looks good to me!

Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved
Comment thread src/tests/test_deps.py Resolved

@frgfm frgfm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot!

@frgfm
frgfm requested a review from florianriche November 21, 2020 13:54
@frgfm
frgfm merged commit 45c43b9 into pyronear:master Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing query filters from list of tuples to dict

3 participants