def test_call_with_params(self): leaf = Leaf(VIN=VIN, custom_sessionid=custom_sessionid) response = leaf.BatteryStatusCheckRequest() assert response['status'] == 200 #time.sleep(140) # only need to pause here when running against live service response2 = leaf.BatteryStatusCheckResultRequest(resultKey=response['resultKey']) assert response2['status'] == 200
def getleaf(): username = os.getenv('username') password = os.getenv('password') leaf = cache.get('leaf') if not leaf: leaf = Leaf(username, password) # Make sure the leaf custom_sessionid is valid try: leaf.BatteryStatusRecordsRequest() except: leaf = Leaf(username, password) cache.set('leaf',leaf) return leaf
def test_call_to_nonexistent_endpoint(self): leaf = Leaf(VIN=VIN, custom_sessionid=custom_sessionid) with self.assertRaises(Exception): response = leaf.this_doesnt_exist()
def test_login_with_no_args_raises_exception(self): with self.assertRaises(Exception): leaf = Leaf()
def test_call_with_no_params(self): leaf = Leaf(VIN=VIN, custom_sessionid=custom_sessionid) result = leaf.BatteryStatusRecordsRequest() assert result['status'] == 200
def test_login_with_only_VIN_raises_exception(self): with self.assertRaises(Exception): leaf = Leaf(VIN='vin123')
def test_login_with_only_custom_sessionid_raises_exception(self): with self.assertRaises(Exception): leaf = Leaf(custom_sessionid='vin123')
def test_login_with_only_username_raises_exception(self): with self.assertRaises(Exception): leaf = Leaf('username')
def test_exception_raised_when_bad_vin_and_customsessionid_used(self): leaf = Leaf(VIN='vin345',custom_sessionid='csid123') with self.assertRaises(Exception) as w: leaf.BatteryStatusRecordsRequest()
def test_exeption_raised_when_bad_credentials_passed(self): with self.assertRaises(Exception) as w: leaf = Leaf('*****@*****.**','invalidpassword')
def test_login_with_custom_sessionid_and_vin(self): leaf = Leaf(VIN='vin345', custom_sessionid='csid123') assert leaf.VIN == 'vin345' assert leaf.custom_sessionid == 'csid123'
def test_login(self): leaf = Leaf(USERNAME, PASSWORD) assert leaf.VIN == "vin123" assert leaf.custom_sessionid == "csessid"