Add publish operation to iotdata (#1362)
* add publish operation to iotdata * restart ci
This commit is contained in:
parent
e227a30aa9
commit
cfc994d0ae
@ -184,6 +184,10 @@ class IoTDataPlaneBackend(BaseBackend):
|
|||||||
thing.thing_shadow = new_shadow
|
thing.thing_shadow = new_shadow
|
||||||
return thing.thing_shadow
|
return thing.thing_shadow
|
||||||
|
|
||||||
|
def publish(self, topic, qos, payload):
|
||||||
|
# do nothing because client won't know about the result
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
available_regions = boto3.session.Session().get_available_regions("iot-data")
|
available_regions = boto3.session.Session().get_available_regions("iot-data")
|
||||||
iotdata_backends = {region: IoTDataPlaneBackend(region) for region in available_regions}
|
iotdata_backends = {region: IoTDataPlaneBackend(region) for region in available_regions}
|
||||||
|
@ -33,3 +33,14 @@ class IoTDataPlaneResponse(BaseResponse):
|
|||||||
thing_name=thing_name,
|
thing_name=thing_name,
|
||||||
)
|
)
|
||||||
return json.dumps(payload.to_dict())
|
return json.dumps(payload.to_dict())
|
||||||
|
|
||||||
|
def publish(self):
|
||||||
|
topic = self._get_param("topic")
|
||||||
|
qos = self._get_int_param("qos")
|
||||||
|
payload = self._get_param("payload")
|
||||||
|
self.iotdata_backend.publish(
|
||||||
|
topic=topic,
|
||||||
|
qos=qos,
|
||||||
|
payload=payload,
|
||||||
|
)
|
||||||
|
return json.dumps(dict())
|
||||||
|
@ -85,3 +85,9 @@ def test_update():
|
|||||||
payload.should.have.key('metadata').which.should.have.key('desired').which.should.have.key('led')
|
payload.should.have.key('metadata').which.should.have.key('desired').which.should.have.key('led')
|
||||||
payload.should.have.key('version').which.should.equal(2)
|
payload.should.have.key('version').which.should.equal(2)
|
||||||
payload.should.have.key('timestamp')
|
payload.should.have.key('timestamp')
|
||||||
|
|
||||||
|
|
||||||
|
@mock_iotdata
|
||||||
|
def test_publish():
|
||||||
|
client = boto3.client('iot-data', region_name='ap-northeast-1')
|
||||||
|
client.publish(topic='test/topic', qos=1, payload=b'')
|
||||||
|
Loading…
Reference in New Issue
Block a user