def test_updateNotificationNoneNone(self, session=None): sm1 = ShakeMap(shakemap_id='shakemap1', shakemap_version=1) sm2 = ShakeMap(shakemap_id='shakemap1', shakemap_version=2) session.add_all([sm1, sm2]) group = create_group(name='GLOBAL') session.add(group) n1 = Notification(shakemap=sm1) n2 = Notification(shakemap=sm2) session.add_all([n1, n2]) session.commit() # check notification 1 has_alert_level, new_inspection, update = check_notification_for_group( group, n2, session=session) self.assertTrue(has_alert_level) self.assertFalse(new_inspection) self.assertTrue(update) objs = [sm1, sm2, n1, n2, group] for obj in objs: session.delete(obj) session.commit()
def test_changedNotificationLength(self, session=None): sm1 = ShakeMap(shakemap_id='test_changedNotificationLength', shakemap_version=1) sm2 = ShakeMap(shakemap_id='test_changedNotificationLength', shakemap_version=2) session.add_all([sm1, sm2]) group = create_group(name='GLOBAL') session.add(group) n1 = Notification(shakemap=sm1) n2 = Notification(shakemap=sm2) session.add_all([n1, n2]) fac1 = Facility(facility_id=1, groups=[group]) fac2 = Facility(facility_id=2, groups=[group]) fac3 = Facility(facility_id=3, groups=[group]) fs1 = FacilityShaking(shakemap=sm1, alert_level='green', facility=fac1) fs2 = FacilityShaking(shakemap=sm2, alert_level='green', facility=fac2) fs3 = FacilityShaking(shakemap=sm2, alert_level='gray', facility=fac3) session.add_all([fac1, fac2, fac3, fs1, fs2, fs3]) session.commit() # check notification 1 has_alert_level, new_inspection, update = check_notification_for_group( group, n2, session=session) self.assertTrue(has_alert_level) self.assertTrue(new_inspection) self.assertTrue(update) objs = [sm1, sm2, n1, n2, group, fac1, fac2, fac3] for obj in objs: session.delete(obj) session.commit()
def test_changedNotificationNoneGrey(self, session=None): sm1 = ShakeMap(shakemap_id='shakemap1', shakemap_version=1) sm2 = ShakeMap(shakemap_id='shakemap1', shakemap_version=2) session.add_all([sm1, sm2]) group = create_group(name='GLOBAL') session.add(group) n1 = Notification(shakemap=sm1) n2 = Notification(shakemap=sm2) session.add_all([n1, n2]) facility = Facility(groups=[group]) fs = FacilityShaking(shakemap=sm2, alert_level='gray', facility=facility) session.add(fs) session.commit() # check notification 1 has_alert_level, new_inspection, update = check_notification_for_group( group, n2, session=session) self.assertTrue(has_alert_level) self.assertTrue(new_inspection) self.assertTrue(update) objs = [sm1, sm2, n1, n2, group] for obj in objs: session.delete(obj) session.commit()
def test_unchangedNotificationGreenGreen(self, session=None): sm1 = ShakeMap(shakemap_id='shakemap1', shakemap_version=1) sm2 = ShakeMap(shakemap_id='shakemap1', shakemap_version=2) session.add_all([sm1, sm2]) group = create_group(name='GLOBAL') session.add(group) n1 = Notification(shakemap=sm1) n2 = Notification(shakemap=sm2) session.add_all([n1, n2]) fac1 = Facility(facility_id=1) fs1 = FacilityShaking(shakemap=sm1, weight=1, facility=fac1) fs2 = FacilityShaking(shakemap=sm2, weight=1, facility=fac1) session.add_all([fac1, fs1, fs2]) session.commit() # check notification 1 has_alert_level, new_inspection, update = check_notification_for_group( group, n2, session=session) self.assertTrue(has_alert_level) self.assertFalse(new_inspection) self.assertTrue(update) objs = [sm1, sm2, n1, n2, group, fac1] for obj in objs: session.delete(obj) session.commit()