def test_receiver_store(self): receiver = rb.Receiver('webhook', CLUSTER_ID, 'test-action', name='test_receiver_123456', project=self.context.project) self.assertIsNone(receiver.id) receiver_id = receiver.store(self.context) self.assertIsNotNone(receiver_id) self.assertEqual(receiver_id, receiver.id) result = ro.Receiver.get(self.context, receiver_id) self.assertIsNotNone(result) self.assertEqual(receiver_id, result.id) self.assertEqual(receiver.type, result.type) self.assertEqual(receiver.name, result.name) self.assertEqual(receiver.user, result.user) self.assertEqual(receiver.project, result.project) self.assertEqual(receiver.domain, result.domain) self.assertEqual(common_utils.isotime(receiver.created_at), common_utils.isotime(result.created_at)), self.assertEqual(receiver.updated_at, result.updated_at) self.assertEqual(receiver.action, result.action) self.assertEqual(receiver.actor, result.actor) self.assertEqual(receiver.params, result.params) self.assertEqual(receiver.channel, result.channel)
def test_receiver_init(self): kwargs = { 'id': UUID1, 'name': 'test-receiver', 'user': '******', 'project': 'test-project', 'domain': 'test-domain', 'created_at': timeutils.utcnow(True), 'updated_at': None, 'actor': self.actor, 'params': self.params, 'channel': { 'alarm_url': 'http://url1' }, } receiver = rb.Receiver('webhook', CLUSTER_ID, 'test-action', **kwargs) self.assertEqual(kwargs['id'], receiver.id) self.assertEqual(kwargs['name'], receiver.name) self.assertEqual('webhook', receiver.type) self.assertEqual('test-action', receiver.action) self.assertEqual(kwargs['user'], receiver.user) self.assertEqual(kwargs['project'], receiver.project) self.assertEqual(kwargs['domain'], receiver.domain) self.assertEqual(kwargs['created_at'], receiver.created_at) self.assertEqual(kwargs['updated_at'], receiver.updated_at) self.assertEqual(CLUSTER_ID, receiver.cluster_id) self.assertEqual('test-action', receiver.action) self.assertEqual(self.actor, receiver.actor) self.assertEqual(self.params, receiver.params) self.assertEqual(kwargs['channel'], receiver.channel)
def test_receiver_store(self): receiver = receiver_mod.Receiver('webhook', 'FAKE_CLUSTER', 'test-action', project=self.context.project) self.assertIsNone(receiver.id) receiver_id = receiver.store(self.context) self.assertIsNotNone(receiver_id) self.assertEqual(receiver_id, receiver.id) result = db_api.receiver_get(self.context, receiver_id) self.assertIsNotNone(result) self.assertEqual(receiver_id, result.id) self.assertEqual(receiver.type, result.type) self.assertEqual(receiver.name, result.name) self.assertEqual(receiver.user, result.user) self.assertEqual(receiver.project, result.project) self.assertEqual(receiver.domain, result.domain) self.assertEqual(receiver.created_at, result.created_at) self.assertEqual(receiver.updated_at, result.updated_at) self.assertEqual(receiver.action, result.action) self.assertEqual(receiver.actor, result.actor) self.assertEqual(receiver.params, result.params) self.assertEqual(receiver.channel, result.channel)
def test_receiver_init_default_value(self): receiver = rb.Receiver('webhook', CLUSTER_ID, 'test-action') self.assertIsNone(receiver.id) self.assertIsNone(receiver.name) self.assertEqual('webhook', receiver.type) self.assertEqual('', receiver.user) self.assertEqual('', receiver.project) self.assertEqual('', receiver.domain) self.assertIsNone(receiver.created_at) self.assertIsNone(receiver.updated_at) self.assertEqual(CLUSTER_ID, receiver.cluster_id) self.assertEqual('test-action', receiver.action) self.assertEqual({}, receiver.actor) self.assertEqual({}, receiver.params) self.assertEqual({}, receiver.channel)