def test_create(self): sot = notification.Notification(**NOTIFICATION) self.assertEqual(NOTIFICATION["id"], sot.id) self.assertEqual(NOTIFICATION["notification_uuid"], sot.notification_uuid) self.assertEqual(NOTIFICATION["created_at"], sot.created_at) self.assertEqual(NOTIFICATION["updated_at"], sot.updated_at) self.assertEqual(NOTIFICATION["type"], sot.type) self.assertEqual(NOTIFICATION["hostname"], sot.hostname) self.assertEqual(NOTIFICATION["status"], sot.status) self.assertEqual(NOTIFICATION["generated_time"], sot.generated_time) self.assertEqual(NOTIFICATION["payload"], sot.payload) self.assertEqual(NOTIFICATION["source_host_uuid"], sot.source_host_uuid)
def test_basic(self): sot = notification.Notification(NOTIFICATION) self.assertEqual("notification", sot.resource_key) self.assertEqual("notifications", sot.resources_key) self.assertEqual("/notifications", sot.base_path) self.assertTrue(sot.allow_list) self.assertTrue(sot.allow_fetch) self.assertTrue(sot.allow_create) self.assertFalse(sot.allow_commit) self.assertFalse(sot.allow_delete) self.assertDictEqual({"generated_since": "generated-since", "limit": "limit", "marker": "marker", "sort_dir": "sort_dir", "sort_key": "sort_key", "source_host_uuid": "source_host_uuid", "status": "status", "type": "type"}, sot._query_mapping._mapping)
def test_create(self): sot = notification.Notification(**NOTIFICATION) rec_workflow_details = NOTIFICATION["recovery_workflow_details"][0] self.assertEqual(NOTIFICATION["id"], sot.id) self.assertEqual( NOTIFICATION["notification_uuid"], sot.notification_uuid) self.assertEqual(NOTIFICATION["created_at"], sot.created_at) self.assertEqual(NOTIFICATION["updated_at"], sot.updated_at) self.assertEqual(NOTIFICATION["type"], sot.type) self.assertEqual(NOTIFICATION["hostname"], sot.hostname) self.assertEqual(NOTIFICATION["status"], sot.status) self.assertEqual(NOTIFICATION["generated_time"], sot.generated_time) self.assertEqual(NOTIFICATION["payload"], sot.payload) self.assertEqual( NOTIFICATION["source_host_uuid"], sot.source_host_uuid) self.assertEqual(rec_workflow_details["name"], sot.recovery_workflow_details[0].name) self.assertEqual(rec_workflow_details["state"], sot.recovery_workflow_details[0].state) self.assertEqual(rec_workflow_details["progress"], sot.recovery_workflow_details[0].progress) self.assertEqual( rec_workflow_details["progress_details"][0]['progress'], sot.recovery_workflow_details[0].progress_details[0].progress) self.assertEqual( rec_workflow_details["progress_details"][0]['message'], sot.recovery_workflow_details[0].progress_details[0].message) self.assertEqual( rec_workflow_details["progress_details"][0]['timestamp'], sot.recovery_workflow_details[0].progress_details[0].timestamp) self.assertIsInstance(sot.recovery_workflow_details, list) self.assertIsInstance( sot.recovery_workflow_details[0].progress_details, list) self.assertIsInstance(sot.recovery_workflow_details[0], notification.RecoveryWorkflowDetailItem) self.assertIsInstance( sot.recovery_workflow_details[0].progress_details[0], notification.ProgressDetailsItem)
def data(TEST): TEST.masakari_segment = test_data_utils.TestDataContainer() segment1 = segment.Segment( uuid=uuidsentinel.segment1, name='test', recovery_method='auto', service_type='service', description='demo', is_enabled=True, ) segment2 = segment.Segment( uuid=uuidsentinel.segment2, name='test2', recovery_method='auto', service_type='service', description='demo', is_enabled=False, ) segment3 = segment.Segment( uuid=uuidsentinel.segment3, name='test3', recovery_method='auto', service_type='service', description='demo', is_enabled=True, ) TEST.masakari_segment.add(segment1) TEST.masakari_segment.add(segment2) TEST.masakari_segment.add(segment3) TEST.masakari_host = test_data_utils.TestDataContainer() host1 = host.Host(uuid=uuidsentinel.host1, name="test", reserved='True', type='service', control_attributes='test', failover_segment_id=uuidsentinel.segment1, on_maintenance='False') TEST.masakari_host.add(host1) TEST.hypervisors = test_data_utils.TestDataContainer() hypervisor1 = Hypervisor(HypervisorManager, { 'id': '1', 'hypervisor_hostname': "test" }) TEST.hypervisors.add(hypervisor1) TEST.masakari_notification = test_data_utils.TestDataContainer() notification1 = notification.Notification( notification_uuid=uuidsentinel.notification1, status='new', generated_time=(NOW - datetime.timedelta(seconds=2)), payload='test', type='type1', source_host_uuid=uuidsentinel.host1) notification2 = notification.Notification( notification_uuid=uuidsentinel.notification2, status='running', generated_time=(NOW - datetime.timedelta(seconds=3)), payload='test', type='type2', source_host_uuid=uuidsentinel.host2) notification3 = notification.Notification( notification_uuid=uuidsentinel.notification3, status='error', generated_time=(NOW - datetime.timedelta(seconds=4)), payload='test', type='type3', source_host_uuid=uuidsentinel.host3) TEST.masakari_notification.add(notification1) TEST.masakari_notification.add(notification2) TEST.masakari_notification.add(notification3)