Ejemplo n.º 1
0
 async def test_respond_room_description(self):
     event = events.RoomDescription("A test room", target="!test:localhost")
     with amock.patch(api_string.format("set_room_topic")) as patched_send:
         patched_send.return_value = asyncio.Future()
         patched_send.return_value.set_result({})
         await self.connector.send(event)
         assert patched_send.called_once_with("#test:localhost", "A test room")
Ejemplo n.º 2
0
 async def topic_changed(self, event, channel):
     """Send a RoomDescription event."""
     _LOGGER.debug(_("New description: %s"), event["topic"])
     _LOGGER.debug(_("Target channel: %s"), event["channel"])
     return events.RoomDescription(
         description=event["topic"],
         target=channel,
         connector=self.connector,
         event_id=event["event_ts"],
         raw_event=event,
     )
Ejemplo n.º 3
0
 async def create_room_description(self, event, roomid):
     """Send a RoomDescriptionEvent."""
     return events.RoomDescription(
         description=event["content"]["topic"],
         user=await self.connector.get_nick(roomid, event["sender"]),
         user_id=event["sender"],
         target=roomid,
         connector=self.connector,
         event_id=event["event_id"],
         raw_event=event,
     )
Ejemplo n.º 4
0
 async def test_send_room_description(self):
     connector = ConnectorSlack({"token": "abc123"}, opsdroid=self.od)
     connector.slack_user.api_call = amock.CoroutineMock()
     await connector.send(
         events.RoomDescription(target="an-existing-room",
                                description="A new description"))
     connector.slack_user.api_call.assert_called_once_with(
         "conversations.setTopic",
         data={
             "channel": "an-existing-room",
             "topic": "A new description"
         },
     )
Ejemplo n.º 5
0
async def test_send_room_description(send_event):
    event = events.RoomDescription(description="Topic Update", target="room")
    payload, response = await send_event(CONVERSATIONS_SET_TOPIC, event)
    assert payload == {"channel": "room", "topic": "Topic Update"}
    assert response["ok"]