Skip to content

Commit

Permalink
Fix broken tests (#11395)
Browse files Browse the repository at this point in the history
* Do not leave remember the milk config file behind

* Fix exception in service causing service timeout

* Change max service timeout to 9 to catch services timing out

* Fix Google Sync service test

* Update and pin test requirements
  • Loading branch information
balloob authored Jan 1, 2018
1 parent b9c8523 commit 6e63a4e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
21 changes: 10 additions & 11 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ flake8==3.3
pylint==1.6.5
mypy==0.560
pydocstyle==1.1.1
coveralls>=1.1
pytest>=2.9.2
pytest-aiohttp>=0.1.3
pytest-cov>=2.3.1
pytest-timeout>=1.2.0
pytest-catchlog>=1.2.2
pytest-sugar>=0.7.1
requests_mock>=1.0
mock-open>=1.3.1
coveralls==1.2.0
pytest==3.3.1
pytest-aiohttp==0.3.0
pytest-cov==2.5.1
pytest-timeout>=1.2.1
pytest-sugar==0.9.0
requests_mock==1.4
mock-open==1.3.1
flake8-docstrings==1.0.2
asynctest>=0.8.0
freezegun>=0.3.8
asynctest>=0.11.1
freezegun==0.3.9
21 changes: 10 additions & 11 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ flake8==3.3
pylint==1.6.5
mypy==0.560
pydocstyle==1.1.1
coveralls>=1.1
pytest>=2.9.2
pytest-aiohttp>=0.1.3
pytest-cov>=2.3.1
pytest-timeout>=1.2.0
pytest-catchlog>=1.2.2
pytest-sugar>=0.7.1
requests_mock>=1.0
mock-open>=1.3.1
coveralls==1.2.0
pytest==3.3.1
pytest-aiohttp==0.3.0
pytest-cov==2.5.1
pytest-timeout>=1.2.1
pytest-sugar==0.9.0
requests_mock==1.4
mock-open==1.3.1
flake8-docstrings==1.0.2
asynctest>=0.8.0
freezegun>=0.3.8
asynctest>=0.11.1
freezegun==0.3.9


# homeassistant.components.notify.html5
Expand Down
20 changes: 11 additions & 9 deletions tests/components/test_remember_the_milk.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def tearDown(self):
def test_create_new(self):
"""Test creating a new config file."""
with patch("builtins.open", mock_open()), \
patch("os.path.isfile", Mock(return_value=False)):
patch("os.path.isfile", Mock(return_value=False)), \
patch.object(rtm.RememberTheMilkConfiguration, 'save_config'):
config = rtm.RememberTheMilkConfiguration(self.hass)
config.set_token(self.profile, self.token)
self.assertEqual(config.get_token(self.profile), self.token)
Expand All @@ -65,16 +66,17 @@ def test_id_map(self):
timeseries_id = "my_timeseries"
rtm_id = "rtm-id-4567"
with patch("builtins.open", mock_open()), \
patch("os.path.isfile", Mock(return_value=False)):
patch("os.path.isfile", Mock(return_value=False)), \
patch.object(rtm.RememberTheMilkConfiguration, 'save_config'):
config = rtm.RememberTheMilkConfiguration(self.hass)

self.assertEqual(None, config.get_rtm_id(self.profile, hass_id))
config.set_rtm_id(self.profile, hass_id, list_id, timeseries_id,
rtm_id)
self.assertEqual((list_id, timeseries_id, rtm_id),
config.get_rtm_id(self.profile, hass_id))
config.delete_rtm_id(self.profile, hass_id)
self.assertEqual(None, config.get_rtm_id(self.profile, hass_id))
self.assertEqual(None, config.get_rtm_id(self.profile, hass_id))
config.set_rtm_id(self.profile, hass_id, list_id, timeseries_id,
rtm_id)
self.assertEqual((list_id, timeseries_id, rtm_id),
config.get_rtm_id(self.profile, hass_id))
config.delete_rtm_id(self.profile, hass_id)
self.assertEqual(None, config.get_rtm_id(self.profile, hass_id))

def test_load_key_map(self):
"""Test loading an existing key map from the file."""
Expand Down
1 change: 1 addition & 0 deletions tests/components/test_shell_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def test_template_render_no_template(self, mock_call):
def test_template_render(self, mock_call):
"""Ensure shell_commands with templates get rendered properly."""
self.hass.states.set('sensor.test_state', 'Works')
mock_call.return_value = mock_process_creator(error=False)
self.assertTrue(
setup_component(self.hass, shell_command.DOMAIN, {
shell_command.DOMAIN: {
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ setenv =
whitelist_externals = /usr/bin/env
install_command = /usr/bin/env LANG=C.UTF-8 pip install {opts} {packages}
commands =
py.test --timeout=15 --duration=10 --cov --cov-report= {posargs}
py.test --timeout=9 --duration=10 --cov --cov-report= {posargs}
deps =
-r{toxinidir}/requirements_test_all.txt
-c{toxinidir}/homeassistant/package_constraints.txt
Expand Down

0 comments on commit 6e63a4e

Please sign in to comment.