Exemplo n.º 1
0
 def test_send(self, mock_post, mock_logger):
     melissa = Melissa(username="******", password="******")
     self.assertTrue(melissa.send('12345678', {'temp': 20}))
     with mock.patch('melissa.wrapper.SESSION.post',
                     side_effect=mocked_requests_post_bad) as mock_post:
         melissa._send_cache = None
         self.assertFalse(melissa.send('12345678', {'temp': 21}))
Exemplo n.º 2
0
 def test_status(self, mocked_get, mocked_post):
     melissa = Melissa(username="******", password="******")
     good_status = melissa.status()
     with mock.patch('melissa.wrapper.SESSION.post',
                     side_effect=mocked_requests_post_bad) as mock_post:
         melissa.fetch_timestamp = None
         bad_status = melissa.status()
     self.assertEqual(good_status, bad_status)
Exemplo n.º 3
0
 def test_sanity_check(self, mock_post):
     melissa = Melissa(username="******", password="******")
     melissa._latest_temp = 28.9
     melissa._latest_status['12345678'] = json.loads(
         load_fixture('status.json'))['provider']
     data = json.loads(load_fixture('bad_temp_status.json'))['provider']
     device = '12345678'
     self.assertFalse(melissa.sanity_check(data, device))
     data = json.loads(load_fixture('bad_hum_status.json'))['provider']
     self.assertFalse(melissa.sanity_check(data, device))
Exemplo n.º 4
0
 def test_cur_settings(self, mocked_get, mocked_post):
     melissa = Melissa(username="******", password="******")
     self.assertEqual(melissa.cur_settings(
         '12345678'), CUR_SETTINGS_DATA_OK)
Exemplo n.º 5
0
 def test_send_ok(self, mock_post):
     melissa = Melissa(username="******", password="******")
     self.assertTrue(melissa.send('12345678', {'temp': 20}))
Exemplo n.º 6
0
 def test_have_connection(self, mock_post):
     melissa = Melissa(username="******", password="******")
     self.assertTrue(melissa.have_connection())
     melissa.access_token = None
     self.assertFalse(melissa.have_connection())
Exemplo n.º 7
0
 def test_fetch_geofences(self, mock_get, mock_post):
     melissa = Melissa(username="******", password="******")
     resp = melissa.fetch_geofences()
     self.assertEqual(resp, FETCH_GEOFENCES_DATA_OK)
Exemplo n.º 8
0
 def test_get_headers(self, mock_post):
     melissa = Melissa(username="******", password="******")
     self.assertEqual(melissa._get_headers(), LOGGED_IN_HEADERS)
Exemplo n.º 9
0
 def test_connect_ok(self, mock_post):
     melissa = Melissa(username="******", password="******")
     self.assertIsNone(melissa._connect())
Exemplo n.º 10
0
 def test_init(self, mock_post):
     melissa = Melissa(username="******", password="******")
     self.assertEqual(melissa.access_token, '12345678')
     self.assertEqual(melissa.refresh_token, '12345678')
     self.assertEqual(melissa.username, '1234')
     self.assertEqual(melissa.password, '4321')