def assertPropertyValue(self, counter_type, value): """ Handler to assert the value returned by the counter_type's calculator on the given sample. """ calculator = get_calculator(counter_type) self.assertEquals( value, calculator(self.previous, self.current, "WMIPropertyName"))
def _get_property_calculator(self, counter_type): calculator = get_raw try: calculator = get_calculator(counter_type) except UndefinedCalculator: self.logger.warning( u"Undefined WMI calculator for counter_type {counter_type}." " Values are reported as RAW.".format( counter_type=counter_type ) ) return calculator
def _get_property_calculator(self, counter_type): """ Return the calculator for the given `counter_type`. Fallback with `get_raw`. """ calculator = get_raw try: calculator = get_calculator(counter_type) except UndefinedCalculator: self.logger.warning( u"Undefined WMI calculator for counter_type {counter_type}." " Values are reported as RAW.".format( counter_type=counter_type)) return calculator
def test_calculator_decorator(self): """ Asssign a calculator to a counter_type. Raise when the calculator is missing. """ @calculator(123456) def do_something(*args, **kwargs): """A function that does something.""" pass self.assertEquals("do_something", do_something.__name__) self.assertEquals("A function that does something.", do_something.__doc__) self.assertTrue(get_calculator(123456)) self.assertRaises(UndefinedCalculator, get_calculator, 654321)
def _get_property_calculator(self, counter_type): """ Return the calculator for the given `counter_type`. Fallback with `get_raw`. """ calculator = get_raw try: calculator = get_calculator(counter_type) except UndefinedCalculator: self.logger.warning( u"Undefined WMI calculator for counter_type {counter_type}." " Values are reported as RAW.".format(counter_type=counter_type) ) return calculator
def assertPropertyValue(self, counter_type, value): """ Handler to assert the value returned by the counter_type's calculator on the given sample. """ calculator = get_calculator(counter_type) self.assertEquals(value, calculator(self.previous, self.current, "WMIPropertyName"))