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

Tests: NotifyMQTT tests with mqtts:// fail on macOS #695

Closed
amotl opened this issue Oct 12, 2022 · 8 comments
Closed

Tests: NotifyMQTT tests with mqtts:// fail on macOS #695

amotl opened this issue Oct 12, 2022 · 8 comments

Comments

@amotl
Copy link
Collaborator

amotl commented Oct 12, 2022

While working on #680, we discovered this the very first time.

For whatever reasons, after pulling, pytest -k test_plugin_mqtt_general now fails on my machine (Python 3.10.7, macOS 10.15), at this spot:

        # A Secure URL
        obj = apprise.Apprise.instantiate(
            'mqtts://user:pass@localhost/my/topic', suppress_exceptions=False)
        assert isinstance(obj, apprise.plugins.NotifyMQTT)
        assert obj.url().startswith('mqtts://user:pass@localhost/my/topic')
>       assert obj.notify(body="test=test") is True
E       AssertionError: assert False is True

Originally posted by @amotl in #680 (comment)

@amotl
Copy link
Collaborator Author

amotl commented Oct 12, 2022

I've been able to confirm that the very same thing happens on GHA/macOS as well [1]. Amongst other tests, it also fails on Windows [2].

[1] https://github.com/panodata/apprise/actions/runs/3238566205/jobs/5306929033#step:8:427
[2] https://github.com/panodata/apprise/actions/runs/3238651908/jobs/5307105561#step:9:874

@caronc
Copy link
Owner

caronc commented Oct 13, 2022

Your enhancement to email has certainly turned into one incredibly deep rabbit hole hasn't it? 😉

I must admit, you're able to put more time so far into this then i have. Will do my best to try and have a peek, but at the rate you're going, you'll have it figured out🙂.

Does the test pass if your just run it, and it alone?

./bin/test.sh mqtt

@amotl
Copy link
Collaborator Author

amotl commented Oct 13, 2022

Your enhancement to email has certainly turned into one incredibly deep rabbit hole hasn't it? 😉

Indeed ;].

At the rate you're going, you'll have it figured out 🙂.

I probably will. I did not care too much about the failing MQTT test yet, but it will become more relevant when bringing it into CI with master...panodata:apprise:amo/gha.

Will do my best to try and have a peek.

Don't worry about it yet. I still have some energy left to hopefully resolve it. On the other hand, I would be very happy if you can have a look at #696, because that has apparently only been introduced by one of your commits recently.

Does the test pass if your just run it, and it alone?

No. It apparently fails deterministically on macOS, also when run in isolation.

pytest -vvv test/test_plugin_mqtt.py -k test_plugin_mqtt_general

@amotl amotl changed the title Test test_plugin_mqtt_general fails on macOS Tests: test_plugin_mqtt_general fails on macOS Oct 13, 2022
@caronc
Copy link
Owner

caronc commented Oct 14, 2022

Don't worry about it yet. I still have some energy left to hopefully resolve it. On the other hand, I would be very happy if you can have a look at #696, because that has apparently only been introduced by one of your commits recently.

This should be resolved now; just re-base with the master 🚀

It's really weird about the mqtt section as no one has been in that area at all (other than your simplifying of plugin.NotifyPlugin to just NotifyPlugin. I"m not sure if that would have any reason to break things though because you had it working beautifully before.

@amotl

This comment was marked as off-topic.

@amotl
Copy link
Collaborator Author

amotl commented Oct 14, 2022

On my machine, when running this test case,

pytest -vvv test/test_plugin_mqtt.py -k test_plugin_mqtt_general

it croaks on this spot,

# A Secure URL
obj = apprise.Apprise.instantiate(
'mqtts://user:pass@localhost/my/topic', suppress_exceptions=False)
assert isinstance(obj, NotifyMQTT)
assert obj.url().startswith('mqtts://user:pass@localhost/my/topic')
assert obj.notify(body="test=test") is True

because result.rc equals 2.

result = self.client.publish(
topic, payload=body, qos=self.qos, retain=False)
if result.rc != mqtt.MQTT_ERR_SUCCESS:
# Toggle our status
self.logger.warning(
'An error (rc={}) occured when sending MQTT to {}'.
format(result.rc, url))
has_error = True
break

No call to the real publish method is ever made. So, the mocking works, but something goes south.

For whatever reasons, I think this is carried forward somehow.

# Send a notification in a situation where our publish failed
publish_result.rc = 2
assert obj.notify(body="test=test") is False
# Toggle our response object back to what it should be
publish_result.rc = 0

The MQTT test cases will be generally improved with #700, similar to the enhancements in #689.

@amotl amotl changed the title Tests: test_plugin_mqtt_general fails on macOS Tests: NotifyMQTT tests with mqtts:// fail on macOS Oct 15, 2022
@amotl
Copy link
Collaborator Author

amotl commented Oct 15, 2022

Hi again,

with a3c4bd0, I have been able to make the TLS test cases work on my macOS/Homebrew installation.

With kind regards,
Andreas.

@amotl
Copy link
Collaborator Author

amotl commented Oct 16, 2022

Thanks for merging #700, Chris. I think it is safe to close this now.

@amotl amotl closed this as completed Oct 16, 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

No branches or pull requests

2 participants