Fix: IoT does not work in server mode (#3644)

Closes #1631
This commit is contained in:
Brian Pandola 2021-02-01 05:15:57 -08:00 committed by GitHub
commit c9dd9cc7f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 120 additions and 13 deletions

View file

@ -1,5 +1,8 @@
from __future__ import unicode_literals
from six.moves.urllib.parse import quote
import pytest
import sure # noqa
import moto.server as server
@ -19,3 +22,22 @@ def test_iotdata_list():
thing_name = "nothing"
res = test_client.get("/things/{}/shadow".format(thing_name))
res.status_code.should.equal(404)
@pytest.mark.parametrize(
"url_encode_topic",
[
pytest.param(True, id="Topic in Path is URL encoded"),
pytest.param(False, id="Topic in Path is *not* URL encoded"),
],
)
@mock_iotdata
def test_publish(url_encode_topic):
backend = server.create_backend_app("iot-data")
test_client = backend.test_client()
topic = "test/topic"
topic_for_path = quote(topic, safe="") if url_encode_topic else topic
result = test_client.post("/topics/{}".format(topic_for_path))
result.status_code.should.equal(200)