def test_setup_endpoint(self): log = logging.getLogger("Test") nmr = NewMessageReceived() nmr.logger = log nmr.connection = MockConnection() # This was a mess to figure out...because I'm importing with from I have to refer to the class it's being # called from and not the actual function that's being imported with mock.patch( "icon_microsoft_teams.triggers.new_message_received.trigger.get_teams_from_microsoft", return_value=[{ "id": "team" }], ): with mock.patch( "icon_microsoft_teams.triggers.new_message_received.trigger.get_channels_from_microsoft", return_value=[{ "id": "channel" }], ): endpoint = nmr.setup_endpoint("channel", "team") self.assertEqual( "https://graph.microsoft.com/beta/teams/team/channels/channel/messages", endpoint)
def test_get_sorted_messages(self, mockGet): log = logging.getLogger("Test") nmr = NewMessageReceived() nmr.logger = log nmr.connection = MockConnection() messages = nmr.get_sorted_messages("http://somefakeendpoint.com") self.assertIsNotNone(messages) self.assertEqual(messages[0].get("body").get("content"), "This should be first") self.assertEqual(messages[-1].get("body").get("content"), "This is very old")