def test_create_requests_session_failed_request(self, mock_session): mock_session.return_value = FakeSession(status_code=400, params={}) auth = {'api_key': 'key'} with patch.object(bugzilla.BugzillaTicket, '_create_requests_session'): ticket = bugzilla.BugzillaTicket(URL, PROJECT, auth=auth) t = ticket._create_requests_session() self.assertIsNone(t)
def test_create_requests_session_kerberos_auth(self, mock_session): mock_session.return_value = FakeSession() with patch.object(bugzilla.BugzillaTicket, '_create_requests_session'): ticket = bugzilla.BugzillaTicket(URL, PROJECT) t = ticket._create_requests_session() mock_session.assert_called_once() self.assertEqual(t, mock_session.return_value)
def test_create_requests_session_api_auth(self, mock_session): mock_session.return_value = FakeSession(params={}) auth = {'api_key': 'key'} with patch.object(bugzilla.BugzillaTicket, '_create_requests_session'): ticket = bugzilla.BugzillaTicket(URL, PROJECT, auth=auth) t = ticket._create_requests_session() self.assertDictEqual(t.params, auth) self.assertEqual(t.verify, False)
def test_create_requests_session_tuple_auth(self, mock_session): mock_session.return_value = FakeSession(params={}) expected_params = {'login': '******', 'password': '******'} with patch.object(bugzilla.BugzillaTicket, '_create_requests_session'): ticket = bugzilla.BugzillaTicket(URL, PROJECT, auth=('username', 'password')) t = ticket._create_requests_session() self.assertDictEqual(t.params, expected_params) self.assertEqual(t.verify, False)