def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover( { 'name': 'cover.test', 'state_topic': 'state-topic', 'get_position_topic': None, 'command_topic': 'command-topic', 'availability_topic': None, 'tilt_command_topic': 'tilt-command-topic', 'tilt_status_topic': 'tilt-status-topic', 'qos': 0, 'retain': False, 'state_open': 'OPEN', 'state_closed': 'CLOSE', 'position_open': 100, 'position_closed': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'payload_available': None, 'payload_not_available': None, 'optimistic': False, 'value_template': None, 'tilt_open_position': 100, 'tilt_closed_position': 0, 'tilt_min': 0, 'tilt_max': 100, 'tilt_optimistic': False, 'tilt_invert_state': False, 'set_position_topic': None, 'set_position_template': None, 'unique_id': None, 'device_config': None, }, None) assert 44 == mqtt_cover.find_percentage_in_range(44) assert 44 == mqtt_cover.find_percentage_in_range(44, 'cover')
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover( name='cover.test', state_topic='state-topic', get_position_topic=None, command_topic='command-topic', availability_topic=None, tilt_command_topic='tilt-command-topic', tilt_status_topic='tilt-status-topic', qos=0, retain=False, state_open='OPEN', state_closed='CLOSE', position_open=80, position_closed=180, payload_open='OPEN', payload_close='CLOSE', payload_stop='STOP', payload_available=None, payload_not_available=None, optimistic=False, value_template=None, tilt_open_position=180, tilt_closed_position=80, tilt_min=80, tilt_max=180, tilt_optimistic=False, tilt_invert=True, set_position_topic=None, set_position_template=None, unique_id=None, device_config=None, discovery_hash=None) assert 120 == mqtt_cover.find_in_range_from_percent(60) assert 120 == mqtt_cover.find_in_range_from_percent(60, 'cover')
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover( { 'name': 'cover.test', 'state_topic': 'state-topic', 'get_position_topic': None, 'command_topic': 'command-topic', 'availability_topic': None, 'tilt_command_topic': 'tilt-command-topic', 'tilt_status_topic': 'tilt-status-topic', 'qos': 0, 'retain': False, 'state_open': 'OPEN', 'state_closed': 'CLOSE', 'position_open': 80, 'position_closed': 180, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'payload_available': None, 'payload_not_available': None, 'optimistic': False, 'value_template': None, 'tilt_open_position': 180, 'tilt_closed_position': 80, 'tilt_min': 80, 'tilt_max': 180, 'tilt_optimistic': False, 'tilt_invert_state': True, 'set_position_topic': None, 'set_position_template': None, 'unique_id': None, 'device_config': None, }, None) assert 120 == mqtt_cover.find_in_range_from_percent(60) assert 120 == mqtt_cover.find_in_range_from_percent(60, 'cover')
def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover( name='cover.test', state_topic='state-topic', get_position_topic=None, command_topic='command-topic', availability_topic=None, tilt_command_topic='tilt-command-topic', tilt_status_topic='tilt-status-topic', qos=0, retain=False, state_open='OPEN', state_closed='CLOSE', position_open=100, position_closed=0, payload_open='OPEN', payload_close='CLOSE', payload_stop='STOP', payload_available=None, payload_not_available=None, optimistic=False, value_template=None, tilt_open_position=100, tilt_closed_position=0, tilt_min=0, tilt_max=100, tilt_optimistic=False, tilt_invert=False, set_position_topic=None, set_position_template=None, unique_id=None, device_config=None, discovery_hash=None) assert 44 == mqtt_cover.find_percentage_in_range(44) assert 44 == mqtt_cover.find_percentage_in_range(44, 'cover')
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover( 'cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 180, 80, 80, 180, False, True) self.assertEqual(120, mqtt_cover.find_in_range_from_percent(60))
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover('cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 180, 80, 80, 180, False, True) self.assertEqual(120, mqtt_cover.find_in_range_from_percent(60))
def test_find_percentage_in_range_altered(self): """Test find percentage in range with altered range.""" mqtt_cover = MqttCover('cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 180, 80, 80, 180, False, False) self.assertEqual(40, mqtt_cover.find_percentage_in_range(120))
def test_find_in_range_defaults_inverted(self): """Test find in range with default range but inverted.""" mqtt_cover = MqttCover('cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 100, 0, 0, 100, False, True) self.assertEqual(44, mqtt_cover.find_in_range_from_percent(56))
def test_find_in_range_defaults_inverted(self): """Test find in range with default range but inverted.""" mqtt_cover = MqttCover( 'cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 100, 0, 0, 100, False, True) self.assertEqual(44, mqtt_cover.find_in_range_from_percent(56))
def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover('cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 100, 0, 0, 100, False, False) self.assertEqual(44, mqtt_cover.find_percentage_in_range(44))
def test_find_percentage_in_range_altered(self): """Test find percentage in range with altered range.""" mqtt_cover = MqttCover( 'cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 180, 80, 80, 180, False, False) self.assertEqual(40, mqtt_cover.find_percentage_in_range(120))
def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover( 'cover.test', 'foo', 'bar', 'fooBar', "fooBarBaz", 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', False, None, 100, 0, 0, 100, False, False) self.assertEqual(44, mqtt_cover.find_percentage_in_range(44))
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover( 'cover.test', 'state-topic', 'command-topic', None, 'tilt-command-topic', 'tilt-status-topic', 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None, False, None, 180, 80, 80, 180, False, True, None, None) self.assertEqual(120, mqtt_cover.find_in_range_from_percent(60))
def test_find_in_range_defaults_inverted(self): """Test find in range with default range but inverted.""" mqtt_cover = MqttCover( 'cover.test', 'state-topic', 'command-topic', None, 'tilt-command-topic', 'tilt-status-topic', 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None, False, None, 100, 0, 0, 100, False, True, None, None) self.assertEqual(44, mqtt_cover.find_in_range_from_percent(56))
def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover( 'cover.test', 'state-topic', 'command-topic', None, 'tilt-command-topic', 'tilt-status-topic', 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None, False, None, 100, 0, 0, 100, False, False, None, None) self.assertEqual(44, mqtt_cover.find_percentage_in_range(44))
def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover('cover.test', 'state-topic', 'command-topic', None, 'tilt-command-topic', 'tilt-status-topic', 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None, False, None, 100, 0, 0, 100, False, False, None, None, None, None, None) self.assertEqual(44, mqtt_cover.find_percentage_in_range(44))
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover('cover.test', 'state-topic', 'command-topic', None, 'tilt-command-topic', 'tilt-status-topic', 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None, False, None, 180, 80, 80, 180, False, True, None, None, None, None, None) self.assertEqual(120, mqtt_cover.find_in_range_from_percent(60))
def test_find_in_range_defaults_inverted(self): """Test find in range with default range but inverted.""" mqtt_cover = MqttCover('cover.test', 'state-topic', 'command-topic', None, 'tilt-command-topic', 'tilt-status-topic', 0, False, 'OPEN', 'CLOSE', 'OPEN', 'CLOSE', 'STOP', None, None, False, None, 100, 0, 0, 100, False, True, None, None, None, None, None) self.assertEqual(44, mqtt_cover.find_in_range_from_percent(56))
def test_find_percentage_in_range_defaults(self): """Test find percentage in range with default range.""" mqtt_cover = MqttCover(name='cover.test', state_topic='state-topic', get_position_topic=None, command_topic='command-topic', availability_topic=None, tilt_command_topic='tilt-command-topic', tilt_status_topic='tilt-status-topic', qos=0, retain=False, state_open='OPEN', state_closed='CLOSE', position_open=100, position_closed=0, payload_open='OPEN', payload_close='CLOSE', payload_stop='STOP', payload_available=None, payload_not_available=None, optimistic=False, value_template=None, tilt_open_position=100, tilt_closed_position=0, tilt_min=0, tilt_max=100, tilt_optimistic=False, tilt_invert=False, set_position_topic=None, set_position_template=None, unique_id=None, device_config=None, discovery_hash=None) assert 44 == mqtt_cover.find_percentage_in_range(44) assert 44 == mqtt_cover.find_percentage_in_range(44, 'cover')
def test_find_in_range_altered_inverted(self): """Test find in range with altered range and inverted.""" mqtt_cover = MqttCover(name='cover.test', state_topic='state-topic', get_position_topic=None, command_topic='command-topic', availability_topic=None, tilt_command_topic='tilt-command-topic', tilt_status_topic='tilt-status-topic', qos=0, retain=False, state_open='OPEN', state_closed='CLOSE', position_open=80, position_closed=180, payload_open='OPEN', payload_close='CLOSE', payload_stop='STOP', payload_available=None, payload_not_available=None, optimistic=False, value_template=None, tilt_open_position=180, tilt_closed_position=80, tilt_min=80, tilt_max=180, tilt_optimistic=False, tilt_invert=True, set_position_topic=None, set_position_template=None, unique_id=None, device_config=None, discovery_hash=None) assert 120 == mqtt_cover.find_in_range_from_percent(60) assert 120 == mqtt_cover.find_in_range_from_percent(60, 'cover')