Example #1
0
 def test_when_ServerBridge_initializes_with_key_it_asks_for_a_token(self):
     with patch('ubidots.apiclient.requests') as mock_request:
         ServerBridge.initialize = self.original_initialize
         apikey = "anyapikey"
         sb = ServerBridge(apikey)
         mock_request.post.assert_called_once_with(
             "%s%s" % (sb.base_url, "auth/token"),
             headers={'content-type': 'application/json', 'X-UBIDOTS-APIKEY': 'anyapikey'}
         )
Example #2
0
 def test_when_ServerBridge_initializes_with_token_it_set_it_correctly(self):
         sb = ServerBridge(token="anytoken")
         self.assertEqual(sb._token_header, {'X-AUTH-TOKEN': 'anytoken'})
Example #3
0
 def setUp(self):
     self.original_initialize = ServerBridge.initialize
     ServerBridge.initialize = MagicMock()
     apikey = "anyapikey"
     self.serverbridge = ServerBridge(apikey)
     self.serverbridge._token_header = {'X-AUTH-TOKEN': 'the token'}