Beispiel #1
0
    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
Beispiel #3
0
    def test_call_to_nonexistent_endpoint(self):
        leaf = Leaf(VIN=VIN, custom_sessionid=custom_sessionid)

        with self.assertRaises(Exception):
            response = leaf.this_doesnt_exist()
Beispiel #4
0
 def test_login_with_no_args_raises_exception(self):
     with self.assertRaises(Exception):
         leaf = Leaf()
Beispiel #5
0
    def test_call_with_no_params(self):
        leaf = Leaf(VIN=VIN, custom_sessionid=custom_sessionid)

        result = leaf.BatteryStatusRecordsRequest()

        assert result['status'] == 200
Beispiel #6
0
 def test_login_with_only_VIN_raises_exception(self):
     with self.assertRaises(Exception):
         leaf = Leaf(VIN='vin123')
Beispiel #7
0
 def test_login_with_only_custom_sessionid_raises_exception(self):
     with self.assertRaises(Exception):
         leaf = Leaf(custom_sessionid='vin123')
Beispiel #8
0
 def test_login_with_only_username_raises_exception(self):
     with self.assertRaises(Exception):
         leaf = Leaf('username')
Beispiel #9
0
    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()
Beispiel #10
0
 def test_exeption_raised_when_bad_credentials_passed(self):
     with self.assertRaises(Exception) as w:
         leaf = Leaf('*****@*****.**','invalidpassword')
Beispiel #11
0
    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'
Beispiel #12
0
    def test_login(self):
        leaf = Leaf(USERNAME, PASSWORD)

        assert leaf.VIN == "vin123"
        assert leaf.custom_sessionid == "csessid"