def test_systemctl_succeed_distinct(self, m_subp): reader = SystemctlReader("dummyProperty", "dummyParameter") val1 = reader.parse_epoch_as_float() m_subp.return_value = ("U=2", None) reader2 = SystemctlReader("dummyProperty", "dummyParameter") val2 = reader2.parse_epoch_as_float() self.assertNotEqual(val1, val2)
def test_systemctl_cannot_convert_epoch_to_float(self, m_subp): reader = SystemctlReader("dummyProperty", "dummyParameter") with self.assertRaises(ValueError): reader.parse_epoch_as_float()
def test_systemctl_epoch_not_splittable(self, m_subp): reader = SystemctlReader("dummyProperty", "dummyParameter") with self.assertRaises(IndexError): reader.parse_epoch_as_float()
def test_systemctl_succeed_zero(self, m_subp): reader = SystemctlReader("dummyProperty", "dummyParameter") self.assertEqual(0.0, reader.parse_epoch_as_float())
def test_systemctl_works_correctly_threshold(self, m_subp): reader = SystemctlReader("dummyProperty", "dummyParameter") self.assertEqual(1.0, reader.parse_epoch_as_float()) thresh = 1.0 - reader.parse_epoch_as_float() self.assertTrue(thresh < 1e-6) self.assertTrue(thresh > (-1 * 1e-6))
def test_systemctl_invalid_parameter(self): reader = SystemctlReader("dummyProperty", "dummyParameter") with self.assertRaises(RuntimeError): reader.parse_epoch_as_float()
def test_systemctl_invalid_property(self): reader = SystemctlReader('dummyProperty') with self.assertRaises(RuntimeError): reader.parse_epoch_as_float()