Unify error messages
Unify error messages for CLI Unify error messages for hub Fixes: https://pagure.io/koji/issue/2720
This commit is contained in:
parent
bbe5b4c703
commit
e784373000
77 changed files with 2170 additions and 348 deletions
38
tests/test_hub/test_getRPM.py
Normal file
38
tests/test_hub/test_getRPM.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import unittest
|
||||
import mock
|
||||
|
||||
import koji
|
||||
import kojihub
|
||||
|
||||
|
||||
class TestGetRPM(unittest.TestCase):
|
||||
|
||||
def test_wrong_type_rpminfo(self):
|
||||
rpminfo = ['test-user']
|
||||
with self.assertRaises(koji.GenericError) as cm:
|
||||
kojihub.get_rpm(rpminfo)
|
||||
self.assertEqual("Invalid type for rpminfo: %s" % type(rpminfo), str(cm.exception))
|
||||
|
||||
|
||||
class TestGetRPMHeaders(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.exports = kojihub.RootExports()
|
||||
self.exports.getLoggedInUser = mock.MagicMock()
|
||||
self.context = mock.patch('kojihub.context').start()
|
||||
self.cursor = mock.MagicMock()
|
||||
|
||||
def test_taskid_invalid_path(self):
|
||||
self.cursor.fetchone.return_value = None
|
||||
self.context.cnx.cursor.return_value = self.cursor
|
||||
filepath = '../test/path'
|
||||
with self.assertRaises(koji.GenericError) as cm:
|
||||
self.exports.getRPMHeaders(taskID=99, filepath=filepath)
|
||||
self.assertEqual("Invalid filepath: %s" % filepath, str(cm.exception))
|
||||
|
||||
def test_taskid_without_filepath(self):
|
||||
self.cursor.fetchone.return_value = None
|
||||
self.context.cnx.cursor.return_value = self.cursor
|
||||
with self.assertRaises(koji.GenericError) as cm:
|
||||
self.exports.getRPMHeaders(taskID=99)
|
||||
self.assertEqual("filepath must be specified with taskID", str(cm.exception))
|
||||
Loading…
Add table
Add a link
Reference in a new issue