def test_step_with_value_error( self, config ): listeners = ['a', 'b', 'c'] data = {} device = '0x13a200409029bf' port = 'adc-1' data[Constants.DataPacket.device] = device data[Constants.DataPacket.port] = port fv = FormatValue() fv.config = {'0x13a200409029bf': {'adc-1': '{:.2a}'}, '0x13a200408cccc3': {'adc-0': '2', 'adc-1': '5'}} with self.assertRaisesRegexp( ValueError, 'The format is incompatable with the input data type {:.2a}: device 0x13a200409029bf port adc-1 file housemonitor.steps.formatvalue: error message Unknown format code .a. for object of type .float.' ): value, data, listeners = fv.step( 1.1111111, data, listeners )
def test_step( self, config ): listeners = ['a', 'b', 'c'] data = {} device = '0x13a200409029bf' port = 'adc-1' data[Constants.DataPacket.device] = device data[Constants.DataPacket.port] = port fv = FormatValue() fv.config = {'0x13a200409029bf': {'adc-1': '{:.2f}'}, '0x13a200408cccc3': {'adc-0': '2', 'adc-1': '5'}} value, data, listeners = fv.step( 1.1111111, data, listeners ) self.assertEqual( value, '1.11' )