コード例 #1
0
ファイル: test_http.py プロジェクト: shubham90/pulp
    def test_send_post_no_auth(self, mock_post):
        notifier_config = {'url': 'https://localhost/api/'}
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            data=data, auth=None
        )
コード例 #2
0
ファイル: test_http.py プロジェクト: grizax/pulp
    def test_send_post_no_auth(self, mock_post):
        notifier_config = {'url': 'https://localhost/api/'}
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            json=data, auth=None
        )
コード例 #3
0
    def test_send_post_no_auth(self, mock_post):
        notifier_config = {'url': 'https://localhost/api/'}
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            data=data,
            headers={'Content-Type': 'application/json'},
            auth=None,
        )
コード例 #4
0
ファイル: test_http.py プロジェクト: alanoe/pulp
    def test_send_post_no_auth(self, mock_post):
        notifier_config = {'url': 'https://localhost/api/'}
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            data=data,
            headers={'Content-Type': 'application/json'},
            auth=None,
        )
コード例 #5
0
ファイル: test_http.py プロジェクト: grizax/pulp
    def test_send_post_auth(self, mock_post, mock_basic_auth):
        notifier_config = {
            'url': 'https://localhost/api/',
            'username': '******',
            'password': '******'
        }
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            json=data,
            auth=mock_basic_auth.return_value
        )
        mock_basic_auth.assert_called_once_with('jcline', 'hunter2')
コード例 #6
0
ファイル: test_http.py プロジェクト: shubham90/pulp
    def test_send_post_auth(self, mock_post, mock_basic_auth):
        notifier_config = {
            'url': 'https://localhost/api/',
            'username': '******',
            'password': '******'
        }
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            data=data,
            auth=mock_basic_auth.return_value
        )
        mock_basic_auth.assert_called_once_with('jcline', 'hunter2')
コード例 #7
0
ファイル: test_http.py プロジェクト: taftsanders/pulp
    def test_send_post_with_ca(self, post):
        notifier_config = {
            'url': 'https://localhost/api/',
            'ca_path': '/tmp/CA',
        }
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        post.assert_called_once_with(
            'https://localhost/api/',
            data=data,
            headers={'Content-Type': 'application/json'},
            auth=None,
            verify=notifier_config['ca_path'],
            timeout=15
        )
コード例 #8
0
    def test_send_post_auth(self, mock_post, mock_basic_auth):
        notifier_config = {
            'url': 'https://localhost/api/',
            'username': '******',
            'password': '******'
        }
        data = {'head': 'feet'}

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            data=data,
            headers={'Content-Type': 'application/json'},
            auth=mock_basic_auth.return_value,
            timeout=15
        )
        mock_basic_auth.assert_called_once_with('jcline', 'hunter2')
コード例 #9
0
ファイル: test_http.py プロジェクト: grizax/pulp
    def test_send_post_bad_response(self, mock_post, mock_basic_auth, mock_log):
        """Assert non-200 posts get logged."""
        expected_log = 'Received HTTP 404 from HTTP notifier to https://localhost/api/.'
        notifier_config = {
            'url': 'https://localhost/api/',
            'username': '******',
            'password': '******'
        }
        data = {'head': 'feet'}
        mock_post.return_value.status_code = 404

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            json=data,
            auth=mock_basic_auth.return_value
        )
        mock_log.error.assert_called_once_with(expected_log)
コード例 #10
0
ファイル: test_http.py プロジェクト: shubham90/pulp
    def test_send_post_bad_response(self, mock_post, mock_basic_auth, mock_log):
        """Assert non-200 posts get logged."""
        expected_log = 'Received HTTP 404 from HTTP notifier to https://localhost/api/.'
        notifier_config = {
            'url': 'https://localhost/api/',
            'username': '******',
            'password': '******'
        }
        data = {'head': 'feet'}
        mock_post.return_value.status_code = 404

        http._send_post(notifier_config, data)
        mock_post.assert_called_once_with(
            'https://localhost/api/',
            data=data,
            auth=mock_basic_auth.return_value
        )
        mock_log.error.assert_called_once_with(expected_log)
コード例 #11
0
 def test_send_post_no_url(self, mock_post, mock_basic_auth, mock_log):
     """Assert attempting to post to no url fails."""
     expected_log = 'HTTP notifier configured without a URL; cannot fire event'
     http._send_post({}, {})
     mock_log.error.assert_called_once_with(expected_log)
     self.assertEqual(0, mock_post.call_count)
コード例 #12
0
ファイル: test_http.py プロジェクト: grizax/pulp
 def test_send_post_no_url(self, mock_post, mock_basic_auth, mock_log):
     """Assert attempting to post to no url fails."""
     expected_log = 'HTTP notifier configured without a URL; cannot fire event'
     http._send_post({}, {})
     mock_log.error.assert_called_once_with(expected_log)
     self.assertEqual(0, mock_post.call_count)