def test_404(self): """Test 404.""" self.mock.send_request.side_effect = error.ClusterFuzzError( 404, 'resp', 'identity') with self.assertRaises(error.InvalidTestcaseIdError) as cm: reproduce.get_testcase_and_identity('12345') self.assertIn('12345', cm.exception.message) self.mock.send_request.assert_called_once_with( reproduce.CLUSTERFUZZ_TESTCASE_INFO_URL, '{"testcaseId": "12345"}')
def test_error(self): """Test other error.""" self.mock.send_request.side_effect = error.ClusterFuzzError( 500, 'resp', 'identity@something') with self.assertRaises(error.ClusterFuzzError) as cm: reproduce.get_testcase_and_identity('12345') self.assertEqual(500, cm.exception.status_code) self.assertIn('resp', cm.exception.message) self.assertIn('identity@something', cm.exception.message) self.mock.send_request.assert_called_once_with( reproduce.CLUSTERFUZZ_TESTCASE_INFO_URL, '{"testcaseId": "12345"}')
def test_succeed(self): """Test succeed.""" self.mock.send_request.return_value = mock.Mock( text='{"test": "ok"}', headers={reproduce.CLUSTERFUZZ_AUTH_IDENTITY: 'identity'}) self.mock.create.return_value = 'dummy testcase' self.assertEqual(('dummy testcase', 'identity'), reproduce.get_testcase_and_identity('12345')) self.mock.send_request.assert_called_once_with( reproduce.CLUSTERFUZZ_TESTCASE_INFO_URL, '{"testcaseId": "12345"}')