def __init__(self, options={}): Common.__init__(self) self.__options = options self.store = {} # replace a lower layer method self._Common__request = self.__request
def test_parse_time_without_micro(self): actual = Common.parse_time("2014-09-05T06:25:29") expect = datetime(2014, 9, 5, 6, 25, 29) self.assertEqual(actual, expect)
def __assert(self, status, expect): self.assertEquals(Common.status_to_hapi_event_type(status), expect)
def test_alarm_to_hapi_status_creation(self): alarm_type = "creation" detail = '{"state": "ok"}' evt_type = Common.alarm_to_hapi_status(alarm_type, detail) self.assertEqual(evt_type, "OK")
def test_alarm_to_hapi_status_unknown(self): alarm_type = "state transition" detail = '{"state": "insufficient data"}' evt_type = Common.alarm_to_hapi_status(alarm_type, detail) self.assertEqual(evt_type, "UNKNOWN")
def test_alarm_to_hapi_status_ng(self): alarm_type = "state transition" detail = '{"state": "alarm"}' evt_type = Common.alarm_to_hapi_status(alarm_type, detail) self.assertEqual(evt_type, "NG")
def test_hapi_time_to_url_enc_openstack_time_with_dot_only(self): hapi_time = "20150624081005." actual = Common.hapi_time_to_url_enc_openstack_time(hapi_time) expect = "2015-06-24T08%3A10%3A05.000000" self.assertEqual(actual, expect)
def test_hapi_time_to_url_enc_openstack_time_with_ns(self): hapi_time = "20150624081005.123456789" actual = Common.hapi_time_to_url_enc_openstack_time(hapi_time) expect = "2015-06-24T08%3A10%3A05.123456" self.assertEqual(actual, expect)