Esempio n. 1
0
def fetch_stream_messages(**kwargs):
    log.info('Fetch Message Stream kwargs: {}'.format(kwargs))
    return dict(
        message=kwargs['message'],
        channel=get_channel_by_id(channel_id=kwargs['channel']),
        published_by_name=get_user_by_id(user_id=kwargs['published_by']).first_name,
        created_on=datetime.now(),
    )
Esempio n. 2
0
    def test_get_channel_by_id_for_value_error(self):
        with self.assertRaises(ValueError) as err_wrong_param:
            channel.get_channel_by_id(channel_id='wrong-id')
        self.channel.deleted_on = '2016-04-04'
        session.flush()
        with self.assertRaises(ValueError) as err_deleted_param:
            channel.get_channel_by_id(channel_id=self.channel_id)
        with self.assertRaises(ValueError) as err_empty_string_param:
            channel.get_channel_by_id(channel_id='')

        self.assertEqual('INVALID-CHANNEL-ID', err_wrong_param.exception.message)
        self.assertEqual('INVALID-CHANNEL-ID', err_deleted_param.exception.message)
        self.assertEqual('REQ-CHANNEL-ID', err_empty_string_param.exception.message)
Esempio n. 3
0
    def test_get_user_by_id_user_for_key_error(self):
        with self.assertRaises(KeyError) as err_empty_param:
            channel.get_channel_by_id(channel_wrong_id=self.channel_id)

        self.assertEqual('REQ-CHANNEL-ID', err_empty_param.exception.message)
Esempio n. 4
0
def user_channel_response_transformation(user_channel_mapping):
    channel_obj = get_channel_by_id(channel_id=user_channel_mapping.channel_id)
    return channel_response_transformation(channel_obj)