class TestChat(unittest.TestCase): def setUp(self): self.rocket = RocketChat() self.user = '******' self.password = '******' self.email = '*****@*****.**' self.rocket.users_register(email=self.email, name=self.user, password=self.password, username=self.user) self.rocket = RocketChat(self.user, self.password) def test_chat_post_update_delete_message(self): chat_post_message = self.rocket.chat_post_message( "hello", channel='GENERAL').json() self.assertEqual(chat_post_message.get('channel'), 'GENERAL') self.assertEqual(chat_post_message.get('message').get('msg'), 'hello') self.assertTrue(chat_post_message.get('success')) with self.assertRaises(RocketMissingParamException): self.rocket.chat_post_message(text='text') msg_id = chat_post_message.get('message').get('_id') chat_get_message = self.rocket.chat_get_message(msg_id=msg_id).json() self.assertEqual(chat_get_message.get('message').get('_id'), msg_id) chat_update = self.rocket.chat_update( room_id=chat_post_message.get('channel'), msg_id=chat_post_message.get('message').get('_id'), text='hello again').json() self.assertEqual(chat_update.get('message').get('msg'), 'hello again') self.assertTrue(chat_update.get('success')) chat_delete = self.rocket.chat_delete( room_id=chat_post_message.get('channel'), msg_id=chat_post_message.get('message').get('_id')).json() self.assertTrue(chat_delete.get('success')) def test_chat_post_react(self): message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_react = self.rocket.chat_react(msg_id=message_id).json() self.assertTrue(chat_react.get('success')) def test_post_pin_unpin(self): message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_pin_message = self.rocket.chat_pin_message(message_id).json() self.assertTrue(chat_pin_message.get('success')) self.assertEqual( chat_pin_message.get('message').get('t'), 'message_pinned') chat_unpin_message = self.rocket.chat_unpin_message(message_id).json() self.assertTrue(chat_unpin_message.get('success')) def test_post_star_unstar(self): message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_star_message = self.rocket.chat_star_message(message_id).json() self.assertTrue(chat_star_message.get('success')) chat_unstar_message = self.rocket.chat_unstar_message( message_id).json() self.assertTrue(chat_unstar_message.get('success')) def test_chat_search(self): chat_search = self.rocket.chat_search(room_id='GENERAL', search_text='hello').json() self.assertTrue(chat_search.get('success')) def test_chat_get_message_read_receipts(self): message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_get_message_read_receipts = self.rocket.chat_get_message_read_receipts( message_id=message_id).json() self.assertTrue(chat_get_message_read_receipts.get('success')) self.assertIn('receipts', chat_get_message_read_receipts)
class TestChat(unittest.TestCase): def setUp(self): self.rocket = RocketChat() self.user = '******' self.password = '******' self.email = '*****@*****.**' self.rocket.users_register(email=self.email, name=self.user, password=self.password, username=self.user) self.rocket = RocketChat(self.user, self.password) def test_chat_post_update_delete_message(self): chat_post_message = self.rocket.chat_post_message( "hello", channel='GENERAL').json() self.assertEqual(chat_post_message.get('channel'), 'GENERAL') self.assertEqual(chat_post_message.get('message').get('msg'), 'hello') self.assertTrue(chat_post_message.get('success')) msg_id = chat_post_message.get('message').get('_id') chat_get_message = self.rocket.chat_get_message(msg_id=msg_id).json() self.assertEqual(chat_get_message.get('message').get('_id'), msg_id) chat_update = self.rocket.chat_update( room_id=chat_post_message.get('channel'), msg_id=chat_post_message.get('message').get('_id'), text='hello again').json() self.assertEqual(chat_update.get('message').get('msg'), 'hello again') self.assertTrue(chat_update.get('success')) chat_delete = self.rocket.chat_delete( room_id=chat_post_message.get('channel'), msg_id=chat_post_message.get('message').get('_id')).json() self.assertTrue(chat_delete.get('success')) def test_chat_post_react(self): self.skipTest("Still not added but already documented endpoint") message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_react = self.rocket.chat_react(msg_id=message_id).json() self.assertTrue(chat_react.get('success')) def test_post_pin_unpin(self): message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_pin_message = self.rocket.chat_pin_message(message_id).json() self.assertTrue(chat_pin_message.get('success')) self.assertEqual( chat_pin_message.get('message').get('t'), 'message_pinned') chat_unpin_message = self.rocket.chat_unpin_message(message_id).json() self.assertTrue(chat_unpin_message.get('success')) def test_post_star_unstar(self): message_id = self.rocket.chat_post_message( "hello", channel='GENERAL').json().get('message').get('_id') chat_star_message = self.rocket.chat_star_message(message_id).json() self.assertTrue(chat_star_message.get('success')) chat_unstar_message = self.rocket.chat_unstar_message( message_id).json() self.assertTrue(chat_unstar_message.get('success'))