コード例 #1
0
 def test_should_verify_ssl(self):
     my_api = api.API("*****@*****.**", session_id=123, server="my3.geotab.com")
     assert my_api._is_verify_ssl is True
     my_api = api.API("*****@*****.**", session_id=123, server="127.0.0.1")
     assert my_api._is_verify_ssl is False
     my_api = api.API("*****@*****.**", session_id=123, server="localhost")
     assert my_api._is_verify_ssl is False
コード例 #2
0
ファイル: test_api_call.py プロジェクト: lt47/mygeotab-python
 def test_username_password_exists(self):
     with pytest.raises(Exception) as excinfo1:
         api.API(None)
     with pytest.raises(Exception) as excinfo2:
         api.API(USERNAME)
     assert "username" in str(excinfo1.value)
     assert "password" in str(excinfo2.value)
コード例 #3
0
ファイル: test_api_call.py プロジェクト: lt47/mygeotab-python
 def test_auth_exception(self):
     test_api = api.API(USERNAME,
                        password="******",
                        database="this_database_does_not_exist")
     with pytest.raises(api.MyGeotabException) as excinfo:
         test_api.authenticate(False)
     assert excinfo.value.name == "DbUnavailableException"
コード例 #4
0
 def test_call_authenticate_invalid_sessionid(self):
     test_api = api.API(FAKE_USERNAME,
                        session_id=FAKE_SESSIONID,
                        database=FAKE_DATABASE)
     with pytest.raises(AuthenticationException) as excinfo:
         test_api.authenticate()
     assert "Cannot authenticate" in str(excinfo.value)
     assert FAKE_DATABASE in str(excinfo.value)
コード例 #5
0
ファイル: test_api_call.py プロジェクト: lt47/mygeotab-python
 def test_invalid_session(self):
     test_api = api.API(USERNAME, session_id="abc123", database=DATABASE)
     assert USERNAME in str(test_api.credentials)
     assert DATABASE in str(test_api.credentials)
     with pytest.raises(api.AuthenticationException) as excinfo:
         test_api.get("User")
     assert "Cannot authenticate" in str(excinfo.value)
     assert DATABASE in str(excinfo.value)
     assert USERNAME in str(excinfo.value)
コード例 #6
0
def mock_api():
    username = "******"
    session_id = 1234
    database = "testdb"

    yield api.API(username,
                  database=database,
                  session_id=session_id,
                  server="https://example.com")
コード例 #7
0
ファイル: test_api_call.py プロジェクト: lt47/mygeotab-python
 def test_call_without_credentials(self):
     if not (USERNAME and PASSWORD):
         pytest.skip("Can't make calls to the API without the "
                     "MYGEOTAB_USERNAME and MYGEOTAB_PASSWORD "
                     "environment variables being set")
     new_api = api.API(USERNAME,
                       password=PASSWORD,
                       database=DATABASE,
                       server=None)
     user = new_api.get("User", name="{0}".format(USERNAME))
     assert len(user) == 1
コード例 #8
0
 def test_invalid_session(self):
     test_api = api.API(FAKE_USERNAME,
                        session_id=FAKE_SESSIONID,
                        database=FAKE_DATABASE)
     assert FAKE_USERNAME in str(test_api.credentials)
     assert FAKE_DATABASE in str(test_api.credentials)
     with pytest.raises(AuthenticationException) as excinfo:
         test_api.get("User")
     assert "Cannot authenticate" in str(excinfo.value)
     assert FAKE_DATABASE in str(excinfo.value)
     assert FAKE_USERNAME in str(excinfo.value)
コード例 #9
0
 def test_call_without_credentials(self):
     if not (USERNAME and PASSWORD):
         pytest.skip('Can\'t make calls to the API without the '
                     'MYGEOTAB_USERNAME and MYGEOTAB_PASSWORD '
                     'environment variables being set')
     new_api = api.API(USERNAME,
                       password=PASSWORD,
                       database=DATABASE,
                       server=None)
     user = new_api.get('User', name='{0}'.format(USERNAME))
     assert len(user) == 1
コード例 #10
0
ファイル: test_api_call.py プロジェクト: lt47/mygeotab-python
def populated_api():
    if USERNAME and PASSWORD:
        session = api.API(USERNAME,
                          password=PASSWORD,
                          database=DATABASE,
                          server=None)
        try:
            session.authenticate()
        except api.MyGeotabException as exception:
            pytest.fail(exception)
            return
        yield session
    else:
        pytest.skip("Can't make calls to the API without the "
                    "MYGEOTAB_USERNAME and MYGEOTAB_PASSWORD "
                    "environment variables being set")