Initial code drop
This commit is contained in:
parent
4967a2a434
commit
5d7e66a17e
126 changed files with 27342 additions and 0 deletions
3
tests/.cvsignore
Normal file
3
tests/.cvsignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*.pyc
|
||||
*.pyo
|
||||
test.py
|
||||
32
tests/runtests.py
Executable file
32
tests/runtests.py
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Wrapper script for running unit tests"""
|
||||
|
||||
__version__ = "$Revision: 1.1 $"
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
testDir = os.path.dirname(sys.argv[0])
|
||||
|
||||
sys.path.insert(0, os.path.abspath('%s/..' % testDir))
|
||||
|
||||
allTests = unittest.TestSuite()
|
||||
for root, dirs, files in os.walk(testDir):
|
||||
common_path = os.path.commonprefix([os.path.abspath(testDir),
|
||||
os.path.abspath(root)])
|
||||
root_path = os.path.abspath(root).replace(common_path, '').lstrip('/').replace('/', '.')
|
||||
|
||||
for test_file in [item for item in files
|
||||
if item.startswith("test_") and item.endswith(".py")]:
|
||||
if len(sys.argv) == 1 or test_file in sys.argv[1:]:
|
||||
print "adding %s..." % test_file
|
||||
test_file = test_file[:-3]
|
||||
if root_path:
|
||||
test_file = "%s.%s" % (root_path, test_file)
|
||||
suite = unittest.defaultTestLoader.loadTestsFromName(test_file)
|
||||
allTests.addTests(suite._tests)
|
||||
|
||||
unittest.TextTestRunner(verbosity=2).run(allTests)
|
||||
67
tests/test___init__.py
Normal file
67
tests/test___init__.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Test the __init__.py module"""
|
||||
|
||||
import koji
|
||||
import unittest
|
||||
|
||||
class INITTestCase(unittest.TestCase):
|
||||
"""Main test case container"""
|
||||
|
||||
def test_parse_NVR(self):
|
||||
"""Test the parse_NVR method"""
|
||||
|
||||
self.assertRaises(AttributeError, koji.parse_NVR, None)
|
||||
self.assertRaises(AttributeError, koji.parse_NVR, 1)
|
||||
self.assertRaises(AttributeError, koji.parse_NVR, {})
|
||||
self.assertRaises(AttributeError, koji.parse_NVR, [])
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVR, "")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVR, "foo")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVR, "foo-1")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVR, "foo-1-")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVR, "foo--1")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVR, "--1")
|
||||
ret = koji.parse_NVR("foo-1-2")
|
||||
self.assertEqual(ret['name'], "foo")
|
||||
self.assertEqual(ret['version'], "1")
|
||||
self.assertEqual(ret['release'], "2")
|
||||
self.assertEqual(ret['epoch'], "")
|
||||
ret = koji.parse_NVR("12:foo-1-2")
|
||||
self.assertEqual(ret['name'], "foo")
|
||||
self.assertEqual(ret['version'], "1")
|
||||
self.assertEqual(ret['release'], "2")
|
||||
self.assertEqual(ret['epoch'], "12")
|
||||
|
||||
def test_parse_NVRA(self):
|
||||
"""Test the parse_NVRA method"""
|
||||
|
||||
self.assertRaises(AttributeError, koji.parse_NVRA, None)
|
||||
self.assertRaises(AttributeError, koji.parse_NVRA, 1)
|
||||
self.assertRaises(AttributeError, koji.parse_NVRA, {})
|
||||
self.assertRaises(AttributeError, koji.parse_NVRA, [])
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1-")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo--1")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "--1")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1-1")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1-1.")
|
||||
self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1.-1")
|
||||
ret = koji.parse_NVRA("foo-1-2.i386")
|
||||
self.assertEqual(ret['name'], "foo")
|
||||
self.assertEqual(ret['version'], "1")
|
||||
self.assertEqual(ret['release'], "2")
|
||||
self.assertEqual(ret['epoch'], "")
|
||||
self.assertEqual(ret['arch'], "i386")
|
||||
self.assertEqual(ret['src'], False)
|
||||
ret = koji.parse_NVRA("12:foo-1-2.src")
|
||||
self.assertEqual(ret['name'], "foo")
|
||||
self.assertEqual(ret['version'], "1")
|
||||
self.assertEqual(ret['release'], "2")
|
||||
self.assertEqual(ret['epoch'], "12")
|
||||
self.assertEqual(ret['arch'], "src")
|
||||
self.assertEqual(ret['src'], True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue