Beispiel #1
0
    def test_email_false(self, mock_glob):
        # setup
        mock_glob.return_value = []

        # run test and check result
        with pytest.raises(ValueError, match='No API key file available'):
            auth.get_auth(use_email=False, email='email', password='******')
Beispiel #2
0
    def test_auth_provided(self, mock_glob):
        # setup
        mock_glob.return_value = []
        expected_return = BaseAuth('api_url')

        # run test
        result = auth.get_auth(seer_auth=expected_return)

        # check result
        assert result == expected_return
Beispiel #3
0
    def test_no_pem_files(self, seer_auth_init, mock_glob):
        # setup
        mock_glob.return_value = []

        # run test
        result = auth.get_auth()

        # check result
        assert isinstance(result, SeerAuth)
        seer_auth_init.assert_called_once_with(mock.ANY,
                                               None,
                                               None,
                                               None,
                                               timeout=None)
Beispiel #4
0
    def test_pem_files_exist(self, seer_key_auth_init, mock_glob):
        # setup
        mock_glob.return_value = ['seerpy.pem']

        # run test and check result
        result = auth.get_auth()

        # check result
        assert isinstance(result, SeerApiKeyAuth)
        seer_key_auth_init.assert_called_once_with(mock.ANY,
                                                   None,
                                                   None,
                                                   None,
                                                   api_url=None,
                                                   timeout=None)
Beispiel #5
0
    def test_use_email(self, seer_auth_init, mock_glob):
        # setup
        mock_glob.return_value = ['seerpy.pem']

        # run test
        result = auth.get_auth(api_key_id='api_key_id',
                               api_key_path='api_key_path',
                               use_email=True)

        # check result
        assert isinstance(result, SeerAuth)
        seer_auth_init.assert_called_once_with(mock.ANY,
                                               None,
                                               None,
                                               None,
                                               timeout=None)
Beispiel #6
0
    def test_email_provided(self, seer_auth_init, mock_glob):
        # setup
        mock_glob.return_value = []

        # run test
        result = auth.get_auth(api_key_id='api_key_id',
                               api_key_path='api_key_path',
                               use_email=None,
                               email='email',
                               password='******')

        # check result
        assert isinstance(result, SeerAuth)
        seer_auth_init.assert_called_once_with(mock.ANY,
                                               None,
                                               'email',
                                               'password',
                                               timeout=None)