From 6e63a4ed8a47c29bbace7c4fb8797565609f9e36 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 1 Jan 2018 14:30:09 -0800 Subject: [PATCH] Fix broken tests (#11395) * 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 --- requirements_test.txt | 21 ++++++++++----------- requirements_test_all.txt | 21 ++++++++++----------- tests/components/test_remember_the_milk.py | 20 +++++++++++--------- tests/components/test_shell_command.py | 1 + tox.ini | 2 +- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/requirements_test.txt b/requirements_test.txt index f224a6f5594..94258f4ffe4 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 543ba3f00a7..97f2821d07e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/test_remember_the_milk.py b/tests/components/test_remember_the_milk.py index 65e7cd73c1f..1b6619aca9c 100644 --- a/tests/components/test_remember_the_milk.py +++ b/tests/components/test_remember_the_milk.py @@ -38,7 +38,8 @@ class TestConfiguration(unittest.TestCase): 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) @@ -65,16 +66,17 @@ class TestConfiguration(unittest.TestCase): 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.""" diff --git a/tests/components/test_shell_command.py b/tests/components/test_shell_command.py index 3bdb6896394..6f993732c38 100644 --- a/tests/components/test_shell_command.py +++ b/tests/components/test_shell_command.py @@ -109,6 +109,7 @@ class TestShellCommand(unittest.TestCase): 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: { diff --git a/tox.ini b/tox.ini index 32f80b95dc1..70612658715 100644 --- a/tox.ini +++ b/tox.ini @@ -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