Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. class TestSmhi(unittest.TestCase):
  2.     """Test the Dark Sky weather component."""
  3.  
  4.     def setUp(self):
  5.         """Set up things to be run when tests are started."""
  6.         self.hass = get_test_home_assistant()
  7.  
  8.     def tearDown(self):
  9.         """Stop down everything that was started."""
  10.         self.hass.stop()
  11.  
  12.     @requests_mock.Mocker()
  13.     def test_setup(self, mock_req):
  14.         """Test for successfully setting up the forecast.io platform."""
  15.         uri = smhi.smhi_lib.APIURL_TEMPLATE.format(TEST_CONFIG['latitude'],
  16.                                                    TEST_CONFIG['longitude'])
  17.         _LOGGER.error(uri)
  18.         mock_req.get(uri,
  19.                      text=load_fixture('smhi.json'))
  20.  
  21.         entry = MockConfigEntry(domain='smhi', data=TEST_CONFIG)
  22.         entry.add_to_hass(self.hass)
  23.         self.assertTrue(setup_component(self.hass, WEATHER_DOMAIN, {
  24.             'weather': {
  25.                 'name': 'test',
  26.                 'platform': 'smhi',
  27.             }
  28.         }))
  29.  
  30.         self.hass.block_till_done()
  31.        
  32.         state = self.hass.states.get('weather.smhi_test')
  33.         self.assertEqual(state.state, 'sunny')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement