1
0
mirror of https://github.com/home-assistant/core.git synced 2025-08-13 15:30:03 +00:00
Files
.github
config
docs
homeassistant
script
tests
components
alarm_control_panel
automation
binary_sensor
camera
climate
cover
device_tracker
fan
light
lock
media_player
mqtt
notify
recorder
sensor
__init__.py
test_command_line.py
test_darksky.py
test_imap_email_content.py
test_mfi.py
test_min_max.py
test_moldindicator.py
test_mqtt.py
test_mqtt_room.py
test_pilight.py
test_random.py
test_rest.py
test_rfxtrx.py
test_sleepiq.py
test_statistics.py
test_tcp.py
test_template.py
test_worldclock.py
test_wunderground.py
test_yahoo_finance.py
test_yr.py
switch
weather
__init__.py
test_alexa.py
test_api.py
test_configurator.py
test_conversation.py
test_demo.py
test_device_sun_light_trigger.py
test_emulated_hue.py
test_frontend.py
test_graphite.py
test_group.py
test_history.py
test_http.py
test_influxdb.py
test_init.py
test_input_boolean.py
test_input_select.py
test_input_slider.py
test_introduction.py
test_logbook.py
test_logentries.py
test_logger.py
test_mqtt_eventstream.py
test_panel_custom.py
test_panel_iframe.py
test_persistent_notification.py
test_pilight.py
test_proximity.py
test_rfxtrx.py
test_scene.py
test_script.py
test_shell_command.py
test_sleepiq.py
test_splunk.py
test_statsd.py
test_sun.py
test_updater.py
test_weblink.py
test_zone.py
fixtures
helpers
resources
scripts
test_util
testing_config
util
__init__.py
common.py
conftest.py
test_bootstrap.py
test_config.py
test_core.py
test_loader.py
test_main.py
test_remote.py
virtualization
.coveragerc
.dockerignore
.gitignore
.gitmodules
.hound.yml
.travis.yml
CONTRIBUTING.md
Dockerfile
LICENSE
MANIFEST.in
README.rst
pylintrc
requirements_all.txt
requirements_docs.txt
requirements_test.txt
setup.cfg
setup.py
tox.ini
core/tests/components/sensor/test_sleepiq.py

51 lines
1.5 KiB
Python

"""The tests for SleepIQ sensor platform."""
import unittest
from unittest.mock import MagicMock
import requests_mock
from homeassistant.components.sensor import sleepiq
from tests.components.test_sleepiq import mock_responses
from tests.common import get_test_home_assistant
class TestSleepIQSensorSetup(unittest.TestCase):
"""Tests the SleepIQ Sensor platform."""
DEVICES = []
def add_devices(self, devices):
"""Mock add devices."""
for device in devices:
self.DEVICES.append(device)
def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.username = 'foo'
self.password = 'bar'
self.config = {
'username': self.username,
'password': self.password,
}
@requests_mock.Mocker()
def test_setup(self, mock):
"""Test for successfully setting up the SleepIQ platform."""
mock_responses(mock)
sleepiq.setup_platform(self.hass,
self.config,
self.add_devices,
MagicMock())
self.assertEqual(2, len(self.DEVICES))
left_side = self.DEVICES[1]
self.assertEqual('SleepNumber ILE Test1 SleepNumber', left_side.name)
self.assertEqual(40, left_side.state)
right_side = self.DEVICES[0]
self.assertEqual('SleepNumber ILE Test2 SleepNumber', right_side.name)
self.assertEqual(80, right_side.state)