Esempio n. 1
0
 def test_creates_request(self):
     with patch(self._get_urlopen_import_path().replace(
             'urlopen', 'Request')) as mock_request:
         tstat = Thermostat(IP)
         tstat.post('/fake', POST_VALUE)
         mock_request.assert_called_once_with(URL, POST_VALUE,
                                              Thermostat.JSON_HEADER)
Esempio n. 2
0
 def test_opens_url(self):
     with patch(self._get_urlopen_import_path()) as mock_urlopen:
         tstat = Thermostat(IP)
         tstat.get('/fake')
         mock_urlopen.assert_called_once_with(URL)
Esempio n. 3
0
 def test_opens_url(self):
     with patch(self._get_urlopen_import_path()) as mock_urlopen:
         tstat = Thermostat(IP)
         tstat.get('/fake')
         mock_urlopen.assert_called_once_with(URL)
 def test_with_fqdn(self):
     tstat = Thermostat('tstat.home.mydomain.org')
     url = tstat._construct_url('/fake')
     self.assertEqual(url, 'http://tstat.home.mydomain.org/fake')
 def test_with_ip(self):
     tstat = Thermostat('192.168.0.2')
     url = tstat._construct_url('/fake')
     self.assertEqual(url, 'http://192.168.0.2/fake')
 def test_trailing_slash_preserved(self):
     tstat = Thermostat('192.168.0.2')
     url = tstat._construct_url('/fake/')
     self.assertEqual(url, 'http://192.168.0.2/fake/')
 def test_without_leading_slash(self):
     tstat = Thermostat('192.168.0.2')
     url = tstat._construct_url('fake')
     self.assertEqual(url, 'http://192.168.0.2/fake')
Esempio n. 8
0
 def test_creates_request(self):
     with patch(self._get_urlopen_import_path().replace('urlopen', 'Request')) as mock_request:
         tstat = Thermostat(IP)
         tstat.post('/fake', POST_VALUE)
         mock_request.assert_called_once_with(URL, POST_VALUE, Thermostat.JSON_HEADER)
Esempio n. 9
0
 def test_calls_urlopen(self):
     with patch(self._get_urlopen_import_path()) as mock_urlopen:
         tstat = Thermostat(IP)
         tstat.post('/fake', POST_VALUE)
         mock_urlopen.assert_called_once_with(FAKE_REQUEST, timeout=4)
Esempio n. 10
0
 def test_calls_urlopen(self):
     with patch(self._get_urlopen_import_path()) as mock_urlopen:
         tstat = Thermostat(IP)
         tstat.post('/fake', POST_VALUE)
         mock_urlopen.assert_called_once_with(FAKE_REQUEST)
Esempio n. 11
0
 def test_with_ip(self):
     tstat = Thermostat('192.168.0.2')
     url = tstat._construct_url('/fake')
     self.assertEqual(url, 'http://192.168.0.2/fake')
Esempio n. 12
0
 def test_trailing_slash_preserved(self):
     tstat = Thermostat('192.168.0.2')
     url = tstat._construct_url('/fake/')
     self.assertEqual(url, 'http://192.168.0.2/fake/')
Esempio n. 13
0
 def test_without_leading_slash(self):
     tstat = Thermostat('192.168.0.2')
     url = tstat._construct_url('fake')
     self.assertEqual(url, 'http://192.168.0.2/fake')
Esempio n. 14
0
 def test_with_fqdn(self):
     tstat = Thermostat('tstat.home.mydomain.org')
     url = tstat._construct_url('/fake')
     self.assertEqual(url, 'http://tstat.home.mydomain.org/fake')