def test_action_help(self): api = bots.create_app().test_client() body = { 'message': 'help', 'metadata': { "orgId": 123, "firebaseToken": channel, "channel": 'canaleta', "senderEmail": "*****@*****.**" } } expected = 'Available commands: help, info, mute<n>, me' rv = api.post(endpoint, json=body) self.assertEqualInDB(rv, channel, expected)
def test_greet_new_user(self): api = bots.create_app().test_client() body = { 'message': 'greet [email protected]', 'metadata': { 'orgId': 123, 'firebaseToken': channel, 'channel': 'canaleta', 'senderEmail': "*****@*****.**" } } expected = "Bienvenido {} al canal {}".format("*****@*****.**", 'canaleta') rv = api.post(endpoint, json=body) self.assertEqualInDB(rv, channel, expected)
def test_user_info(self): api = bots.create_app().test_client() apiToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1ZDAxNzI0NzhjNmI4ZDAwMTcxODU0NDgifQ.tMtWn63rqytzXuLDtrT0wHj_84eGzJ_BmZ8rniNnU5w" body = { 'message': 'me', 'metadata': { 'orgId': 'admin2019', 'firebaseToken': channel, 'channel': 'general', 'senderEmail': "*****@*****.**", 'apiToken': apiToken } } expected = "username {}, alias {}. Contact {}"\ .format("victoria","vicky","*****@*****.**") rv = api.post(endpoint, json=body) # rv.data = rv.data.decode('string-escape').strip('"')[:-2] self.assertEqualInDB(rv, channel, expected)
def test_channel_info(self): api = bots.create_app().test_client() channel = "5d0257e9b3a8033023c420e5" apiToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1ZDAxNzI0NzhjNmI4ZDAwMTcxODU0NDgifQ.tMtWn63rqytzXuLDtrT0wHj_84eGzJ_BmZ8rniNnU5w" body = { 'message': 'info', 'metadata': { 'firebaseToken': channel, 'channel': 'general', 'senderEmail': "*****@*****.**", 'apiToken': apiToken, 'orgId': "admin2019", } } url = str(urls.urls['hypechat']['channelInfo'].format( orgId="admin2019", channelName="general", token=apiToken)) expected = u"Canal: general, Integrandes: [u'*****@*****.**', u'*****@*****.**', u'*****@*****.**'], Cantidad de Mensajes: 5d0257e9b3a8033023c420e5, Descripcion: Canal general, Duenio: [email protected]" rv = api.post(endpoint, json=body) self.assertEqualInDB(rv, channel, expected)
def test_action_help(self): api = bots.create_app().test_client() body = {'message': 'help', 'metadata': ''} expected = 'Available commands: help, info, mute<n>, me' rv = api.post(endpoint, data=body) self.assertEqual(rv.data.rstrip("\n").replace('"', ''), expected)