'Test the WUnderground sensor class and methods.'

@unittest.mock.patch('requests.get', side_effect=mocked_requests_get)
def test_sensor(self, req_mock):

    wunderground.setup_platform(self.hass, VALID_CONFIG, self.add_devices, None)
    for device in self.DEVICES:
        device.update()
        self.assertTrue(str(device.name).startswith('PWS_'))
        if (device.name == 'PWS_weather'):
            self.assertEqual(HTTPS_ICON_URL, device.entity_picture)
            self.assertEqual(WEATHER, device.state)
            self.assertIsNone(device.unit_of_measurement)
        elif (device.name == 'PWS_alerts'):
            self.assertEqual(1, device.state)
            self.assertEqual(ALERT_MESSAGE, device.device_state_attributes['Message'])
            self.assertIsNone(device.entity_picture)
        elif (device.name == 'PWS_location'):
            self.assertEqual('Holly    Springs,    NC', device.state)
        elif (device.name == 'PWS_elevation'):
            self.assertEqual('413', device.state)
        elif (device.name == 'PWS_feelslike_c'):
            self.assertIsNone(device.entity_picture)
            self.assertEqual(FEELS_LIKE, device.state)
            self.assertEqual(TEMP_CELSIUS, device.unit_of_measurement)
        elif (device.name == 'PWS_weather_1d_metric'):
            self.assertEqual(FORECAST_TEXT, device.state)
        else:
            self.assertEqual(device.name, 'PWS_precip_1d_in')
            self.assertEqual(PRECIP_IN, device.state)
            self.assertEqual(LENGTH_INCHES, device.unit_of_measurement)
