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

Add more tests #149

Merged
merged 1 commit into from
Nov 5, 2022
Merged

Add more tests #149

merged 1 commit into from
Nov 5, 2022

Conversation

JonathanPlasse
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Merging #149 (9f8a3d8) into master (d2e713d) will increase coverage by 3.15%.
The diff coverage is 100.00%.

❗ Current head 9f8a3d8 differs from pull request most recent head 97d2053. Consider uploading reports for the commit 97d2053 to get more accurate results

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   86.27%   89.43%   +3.15%     
==========================================
  Files           7        8       +1     
  Lines         430      549     +119     
  Branches        0      109     +109     
==========================================
+ Hits          371      491     +120     
+ Misses         59       37      -22     
- Partials        0       21      +21     
Impacted Files Coverage Δ
asyncio_mqtt/__init__.py 100.00% <100.00%> (ø)
asyncio_mqtt/client.py 80.60% <100.00%> (-3.58%) ⬇️
tests/conftest.py 100.00% <100.00%> (+16.66%) ⬆️
tests/test_client.py 100.00% <100.00%> (ø)
tests/test_error.py 100.00% <100.00%> (ø)
asyncio_mqtt/error.py 100.00% <0.00%> (+38.46%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@JonathanPlasse JonathanPlasse marked this pull request as ready for review November 4, 2022 15:55
@JonathanPlasse
Copy link
Collaborator Author

I added tests for nearly any configuration of Client. The rest of the missing coverage is error handling.
@frederikaalund, @empicano, any feedback.

@frederikaalund
Copy link
Collaborator

I really like this initiative to add more "robustness" to asyncio-mqtt via tests. 👍 Great job on that. 😃
It looks good from my cursory reading!

I don't have enough time tonight to give the proper review that this effort deserves (I already wrote a lengthy reply to another PR). I'll do a review later this weekend when I have the time. :)

Sorry about the lack of time on my part. It's been a busy week at work. I'll try to make up for it this weekend.

~Frederik

Copy link
Collaborator

@frederikaalund frederikaalund left a comment

Choose a reason for hiding this comment

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

LGTM. 👍 Well done! 😄

I put some minor remarks in the comments (mostly pointing to future API decisions). I don't have any requests for changes.

Really great to see our test coverage increase like this. I especially like how you exercised some of the subtle details in our API (the "backpressure" semantics). I think that most people don't realize how important that aspect actually is. Not before it's too late at least! 😄 See some of the early issues for reference.

asyncio_mqtt/client.py Show resolved Hide resolved
asyncio_mqtt/error.py Outdated Show resolved Hide resolved

@pytest.fixture
def anyio_backend() -> Tuple[str, Dict[str, Any]]:
def anyio_backend() -> tuple[str, dict[str, Any]]:
if sys.platform == "win32":
from asyncio.windows_events import WindowsSelectorEventLoopPolicy
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should do something similar to this in the regular lib as well. We get a lot of issues from Windows users due to this.

tests/test_client.py Outdated Show resolved Hide resolved
tests/test_client.py Show resolved Hide resolved
assert logger == client._client._logger # type: ignore[attr-defined]


async def test_client_max_concurrent_outgoing_calls(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now this is an interesting test! Well done. 👍

I wonder how many people actually use this feature in production. 😄

This also showcases a weakness in our current API: We don't have any backpressure mechanics. That is difficult to solve "right", though. Definitely a 2.0 kind of thing (or with the anyio rewrite/replacement).

If you're interested in that kind of stuff there is a good discussion here: python-trio/trio#987

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is not max_concurrent_outgoing_calls a backpressure mechanism?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is but it is a very crude one at that. 😄 My point is that we can and should do better in a future API.

tests/test_client.py Show resolved Hide resolved
tests/test_client.py Show resolved Hide resolved
tests/test_client.py Show resolved Hide resolved
tests/test_error.py Show resolved Hide resolved
@JonathanPlasse
Copy link
Collaborator Author

I added a test that there is no warning for pending calls when max_concurrent_outgoing_calls is set.

@JonathanPlasse JonathanPlasse merged commit 0e3c83f into empicano:master Nov 5, 2022
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