# pyfedpkg.tests - run some simple tests on fedpkg import os import sys from pyfedpkg import _run_command def run(*args, **kwargs): print " CMD:", args, kwargs _run_command(*args, **kwargs) __all__ = [ 'tests' ] def int_test_clone(fedpkg, anonymous): package_name = 'lsnipes' cmd = list(fedpkg) if anonymous: cmd.extend(['clone', '-a', package_name]) else: cmd.extend(['clone', package_name]) run(cmd) oldcwd = os.getcwd() os.chdir(package_name) cmd = list(fedpkg) cmd.extend(['srpm']) run(cmd) cmd = list(fedpkg) cmd.extend(['local']) run(cmd) cmd = list(fedpkg) cmd.extend(['lint']) run(cmd) def test_anon_clone(fedpkg): int_test_clone(fedpkg, anonymous=True) def test_user_clone(fedpkg): int_test_clone(fedpkg, anonymous=False) def test_foo(cmd): pass def tests(fedpkg): if type(fedpkg) == type([]): pass else: fedpkg = [ fedpkg ] print "Running tests on", repr(fedpkg) mod = sys.modules[__name__] for fname in [ x for x in dir(mod) if x.startswith('test_') ]: fun = getattr(mod, fname) print "TC", fname oldcwd = os.getcwd() os.makedirs(fname) os.chdir(fname) fun(list(fedpkg)) os.chdir(oldcwd) run(['rm', '-rf', fname]) if __name__ == '__main__': tests(sys.argv[1:])