def test_create_user_channel_no_schedule(self, *args): protocol_vo = ProtocolFactory(domain_id=self.domain_id) protocol_id = protocol_vo.protocol_id params = { 'name': 'Test User Channel', 'protocol_id': protocol_id, 'user_id': 'bluese05', 'data': { 'token': 'xxxxxx', 'channel': 'bob' }, 'is_scheduled': False, 'schedule': None, 'tags': { utils.random_string(): utils.random_string() }, 'domain_id': self.domain_id } self.transaction.method = 'create' user_ch_svc = UserChannelService(transaction=self.transaction) user_ch_vo = user_ch_svc.create(params.copy()) print_data(user_ch_vo.to_dict(), 'test_create_project_channel') UserChannelInfo(user_ch_vo) self.assertIsInstance(user_ch_vo, UserChannel) self.assertEqual(params['name'], user_ch_vo.name) self.assertEqual(False, user_ch_vo.is_scheduled) self.assertEqual(None, user_ch_vo.schedule) self.assertEqual(False, user_ch_vo.is_subscribe) self.assertEqual(None, user_ch_vo.secret_id) self.assertEqual(params['tags'], user_ch_vo.tags) self.assertEqual(params['domain_id'], user_ch_vo.domain_id)
def test_create_user_channel_secret(self, *args): protocol_capability = { 'data_type': 'SECRET', 'supported_schema': ['slack_webhook'] } protocol_vo = ProtocolFactory(domain_id=self.domain_id, capability=protocol_capability) protocol_id = protocol_vo.protocol_id params = { 'name': 'Test User Channel', 'protocol_id': protocol_id, 'schema': 'slack_webhook', 'user_id': 'bluese05', 'data': { 'token': 'xxxxxx', 'channel': 'bob' }, 'is_scheduled': True, 'schedule': { 'day_of_week': ['MON'], 'start_hour': 1, 'end_hour': 10 }, 'tags': { utils.random_string(): utils.random_string() }, 'domain_id': self.domain_id } self.transaction.method = 'create' user_ch_svc = UserChannelService(transaction=self.transaction) user_ch_vo = user_ch_svc.create(params.copy()) print_data(user_ch_vo.to_dict(), 'test_create_project_channel') UserChannelInfo(user_ch_vo) self.assertIsInstance(user_ch_vo, UserChannel) self.assertEqual(params['name'], user_ch_vo.name) self.assertEqual(True, user_ch_vo.is_scheduled) self.assertEqual(False, user_ch_vo.is_subscribe) self.assertEqual('secret-xyz', user_ch_vo.secret_id) self.assertEqual({}, user_ch_vo.data) self.assertEqual(params['schedule']['day_of_week'], user_ch_vo.schedule.day_of_week) self.assertEqual(params['schedule']['start_hour'], user_ch_vo.schedule.start_hour) self.assertEqual(params['tags'], user_ch_vo.tags) self.assertEqual(params['domain_id'], user_ch_vo.domain_id)
def test_create_user_channel_secret(self, *args): protocol_vo = ProtocolFactory(domain_id=self.domain_id) protocol_id = protocol_vo.protocol_id params = { 'name': 'Test User Channel', 'protocol_id': protocol_id, 'user_id': 'bluese05', 'data': { 'phone_number': '0107772222' }, 'is_scheduled': True, 'schedule': { 'day_of_week': ['MON'], 'start_hour': 1, 'end_hour': 10 }, 'tags': { utils.random_string(): utils.random_string() }, 'domain_id': self.domain_id } self.transaction.method = 'create' user_ch_svc = UserChannelService(transaction=self.transaction) user_ch_vo = user_ch_svc.create(params.copy()) print_data(user_ch_vo.to_dict(), 'test_create_project_channel') UserChannelInfo(user_ch_vo) self.assertIsInstance(user_ch_vo, UserChannel) self.assertEqual(params['name'], user_ch_vo.name) self.assertEqual(True, user_ch_vo.is_scheduled) self.assertEqual(False, user_ch_vo.is_subscribe) self.assertEqual(None, user_ch_vo.secret_id) self.assertEqual({'phone_number': '0107772222'}, user_ch_vo.data) self.assertEqual(params['schedule']['day_of_week'], user_ch_vo.schedule.day_of_week) self.assertEqual(params['schedule']['start_hour'], user_ch_vo.schedule.start_hour) self.assertEqual(params['tags'], user_ch_vo.tags) self.assertEqual(params['domain_id'], user_ch_vo.domain_id)