Ejemplo n.º 1
0
 def test_add_attachment(self, mock_session, mock_open, mock_guess_type, mock_encode, mock_content):
     mock_session.return_value = FakeSession()
     ticket = bugzilla.BugzillaTicket(URL, PROJECT, ticket_id=TICKET_ID)
     t = ticket.add_attachment('file_name', 'data', 'summary')
     self.assertEqual(t, mock_content.return_value)
Ejemplo n.º 2
0
 def test_add_attachment_error(self, mock_session, mock_open, mock_guess_type, mock_encode):
     mock_session.return_value = FakeSession(status_code=401)
     ticket = bugzilla.BugzillaTicket(URL, PROJECT, ticket_id=TICKET_ID)
     t = ticket.add_attachment('file_name', 'data', 'summary')
     self.assertEqual(t, RETURN_RESULT('Failure', 'There is some error.', TICKET_URL, None))
Ejemplo n.º 3
0
 def test_add_attachment_ioerror(self, mock_session):
     mock_session.return_value = FakeSession()
     ticket = bugzilla.BugzillaTicket(URL, PROJECT, ticket_id=TICKET_ID)
     t = ticket.add_attachment('file_name', 'data', 'summary')
     self.assertEqual(t, RETURN_RESULT('Failure', 'File file_name not found', TICKET_URL, None))
Ejemplo n.º 4
0
 def test_add_attachment_unexpected_response(self, mock_session, mock_id, mock_project, mock_open, mock_guess_type,
                                             mock_encode):
     mock_session.return_value = FakeSession(status_code=400)
     ticket = bugzilla.BugzillaTicket(URL, PROJECT, ticket_id=TICKET_ID)
     t = ticket.add_attachment('file_name', 'data', 'summary')
     self.assertEqual(t, RETURN_RESULT('Failure', '', TICKET_URL, None))
Ejemplo n.º 5
0
 def test_add_attachment_no_id(self, mock_session):
     mock_session.return_value = FakeSession()
     ticket = bugzilla.BugzillaTicket(URL, PROJECT)
     t = ticket.add_attachment('file_name', 'data', 'summary')
     self.assertEqual(t, FAILURE_RESULT._replace(error_message=ERROR_MESSAGE))