Beispiel #1
0
def run_tests(verbosity=1):
    try:
        # Support for testoob to have nice colored output
        import testoob
        testoob.main(suite())
    except ImportError:
        runner = unittest.TextTestRunner(verbosity=verbosity)
        runner.run(suite())
def test():
    try:
        # Support for testoob to have nice colored output
        import testoob
        testoob.main(suite())
    except ImportError:
        runner = unittest.TextTestRunner(verbosity=2)
        runner.run(suite())
Beispiel #3
0
def run_test(prefix='test'):
    try:
        import testoob
        testoob.main()
    except ImportError:
        loader = unittest.defaultTestLoader
        loader.testMethodPrefix = prefix
        unittest.main(testLoader = loader)
Beispiel #4
0
def test_main():
    if not os.path.exists('test'):
        os.mkdir('test')
    if '-i' in sys.argv:
        global interactive
        interactive = 1
        sys.argv.remove('-i')
    setup_logging()
    logging.getLogger('ZEO').setLevel(logging.WARNING)
    testoob.main()
Beispiel #5
0
#!/usr/bin/env python
"""
Run unit tests in *Tests.py
"""

import glob, os.path, testoob, unittest

for moduleFilename in glob.glob('*Tests.py'):
    moduleName, _ = os.path.splitext(moduleFilename)
    module = __import__(moduleName)

    for moduleAttrName in dir(module):
        if moduleAttrName.endswith('Tests'):
            globals()[moduleAttrName] = getattr(module, moduleAttrName)

# Start program
if __name__ == "__main__":
    testoob.main()
Beispiel #6
0
import unittest

from clientCalls import *

def suite():
	""" This defines all the tests of a module"""
	suite =unittest.TestSuite()
	suite.addTest(unittest.makeSuite(clientCalls))
	
	return suite

#if __name__ == '__main__':
#        unittest.TextTestRunner(verbosity=2).run(suite())
		
if __name__ == '__main__':
	import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='istorage.html', xml='istorage.xml')
Beispiel #7
0
    return jcl.tests.suite()

if __name__ == '__main__':
    class MyTestProgram(unittest.TestProgram):
        def runTests(self):
            """run tests but do not exit after"""
            self.testRunner = unittest.TextTestRunner(verbosity=self.verbosity)
            self.testRunner.run(self.test)

    logger = logging.getLogger()
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(logging.CRITICAL)
    try:
        print "Trying to launch test with testoob"
        import testoob
        testoob.main(defaultTest='suite')
    except ImportError:
        print "Falling back to standard unittest"
        MyTestProgram(defaultTest='suite')

coverage.report(["src/jcl/__init__.py",
                 "src/jcl/lang.py",
                 "src/jcl/runner.py",
                 "src/jcl/error.py",
                 "src/jcl/jabber/__init__.py",
                 "src/jcl/jabber/component.py",
                 "src/jcl/jabber/command.py",
                 "src/jcl/jabber/feeder.py",
                 "src/jcl/jabber/message.py",
                 "src/jcl/jabber/presence.py",
                 "src/jcl/jabber/disco.py",
Beispiel #8
0
                zauth = AuthSystem.getUntrustedToken(Constants.ZID)
                user_query = {Constants.USER_QUERY: Constants.SELF_QUERY , "params": {"type": Constants.DELTATYPE}}
                ret,result = self.check_pass(user_blob_queryDeltas , [zauth , user_query])
                delta_id = []
                for item in result['deltas']:
                        delta_id.append(item['delta_id'])
                ids = ",".join(delta_id)
                zauth = AuthSystem.getReadonlyToken(Constants.ZID)
                ret,result = self.check_fail(user_blob_deleteDeltas , [zauth , ids])


	def test_user_blob_deleteDeltas_expired_auth(self):
                zauth = AuthSystem.getUntrustedToken(Constants.ZID)
                user_query = {Constants.USER_QUERY: Constants.SELF_QUERY , "params": {"type": Constants.DELTATYPE}}
                ret,result = self.check_pass(user_blob_queryDeltas , [zauth , user_query])
                delta_id = []
                for item in result['deltas']:
                        delta_id.append(item['delta_id'])
                ids = ",".join(delta_id)
                zauth = AuthSystem.getExpiredToken(Constants.ZID)
                ret,result = self.check_fail(user_blob_deleteDeltas , [zauth , ids])

						
if __name__ == '__main__':
        #suite0 = unittest.TestLoader().loadTestsFromTestCase(iauth_unit)
        #unittest.TextTestRunner(verbosity=99).run(suite0)
	import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='/opt/zynga/greyhound/current/gh_test/scripts/test/results/iauth.html')

Beispiel #9
0
"""
Pure unit tests for the Spacewalk backend Python code.

These tests should require no network or disk access and run on just about
any system.
"""

import sys
import unittest

sys.path.insert(0, '../')
sys.path.insert(0, './suites')
sys.path.insert(0, '../../client/rhel/rhnlib')

# Import all test modules here:
import rhnsqltests


def suite():
    # Append all test suites here:
    return unittest.TestSuite((rhnsqltests.suite(), ))


if __name__ == "__main__":
    try:
        import testoob
        testoob.main(defaultTest="suite")
    except ImportError:
        print "These tests would run prettier if you install testoob. :)"
        unittest.main(defaultTest="suite")
Beispiel #10
0
These tests should require no network or disk access and run on just about
any system.
"""

import sys
import unittest

sys.path.insert(0, '../')
sys.path.insert(0, './suites')
sys.path.insert(0, '../../client/rhel/rhnlib')

# Import all test modules here:
import rhnsqltests



def suite():
    # Append all test suites here:
    return unittest.TestSuite((
        rhnsqltests.suite(),
   ))

if __name__ == "__main__":
    try:
        import testoob
        testoob.main(defaultTest="suite")
    except ImportError:
        print "These tests would run prettier if you install testoob. :)"
        unittest.main(defaultTest="suite")
Beispiel #11
0
		status, ret = sendRequest(self.url, self.input)
		self.assertFalse(status, msg=ret)
		self.assertTrue(ret == constants.ERROR_INTERNAL, msg=ret)

	def test_invalidMax(self):
		self.input[constants.ACSKEY_SCOREBOARD][0]['max'] = '12k'
		status, ret = sendRequest(self.url, self.input)
		self.assertFalse(status, msg=ret)
		self.assertTrue(ret == constants.ERROR_INTERNAL, msg=ret)
	

        def _processTest(self, data ):
                status, ret = sendRequest(self.url, data)
                self.assertTrue(status, msg=ret)
                obj = compareFiles(self.input)
                return obj

	def _getDataFromServer(self, data):
		status, ret = sendRequest(self.url, data)
		self.assertTrue(status, msg=ret)
		return ret



if __name__ == '__main__':
        #suite0 = unittest.TestLoader().loadTestsFromTestCase(configSet)
        #unittest.TextTestRunner(verbosity=99).run(suite0)
        import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='FormatChecks.html')
Beispiel #12
0
def LoadAndRunTests(options=None):
    if options is None or len(options.params) == 0:
        name = 'integTests.xml'
        options.params.append(name)
    else:
        name = options.params[0]
    if options.no_sync is None:
        useDefault = False
        if options.use_default is not None:
            useDefault = True
        if options.dry_run is None:
            SyncUpTestData(useDefault)
    else:
        logging.info("VM and hostd data not sync'd by operator command")
    if os.path.exists(name):
        prc = TestOptionParser(name)
        prc.Parse()
        if options.creds is not None:
            prc.UpdateCreds(options.creds)
        prc.SetConnectionInfo(options.type)
        optArgs = prc.GetOpts()
        testDir = './integtests.d'
        if not os.path.exists(testDir):
            raise IOError("Missing directory contianing tests: " + testDir)
        logging.info("Loading Tests...")
        mods = prc.GetModuleList(testDir)
        if len(mods) == 0:
            raise IOError("No test modules were found(or enabled)")
        try:
            skippedMods = []
            for ix in mods:
                try:
                    __import__(ix)
                except ImportError, msg:
                    skippedMods.append((ix, sys.exc_info()))
                    mods.remove(ix)

            suite = unittest.TestLoader().loadTestsFromNames(mods)
            if options.filter:
                ftr = FilterSuite(suite, options.filter)
                suite = ftr.GetSuite()
            if options.dry_run:
                if suite.countTestCases() == 0:
                    logging.info("No TestCases found in TestSuite")
                    return
                print "Tests selected to run are:"
                tests = {
                }  # key is name of TestCase class, data is list of test_*()
                CollectTests(suite, tests)
                objs = 0
                funcs = 0
                for item in tests.keys():
                    print " ", item
                    objs += 1
                    for test in tests[item]:
                        print "    ", test
                        funcs += 1
                logging.info("Totals: TestCases: %d Functions: %d " %
                             (objs, funcs))
                return
            ##try:
            logging.info("Starting Tests")
            testoob.main(suite, None, **optArgs)
            ##except SystemExit, arg:
            if len(skippedMods) > 0:
                logging.error("%s test(s) failed to load." %
                              (len(skippedMods), ))
                import traceback
                for testName, err in skippedMods:
                    print ">>> %s\n%s" % (testName, ''.join(
                        traceback.format_exception(*err)))
                ##raise
        except ImportError:
            raise IOError("Loading test module failed, see prior error.")
Beispiel #13
0
                else:
                        cas = result[ Constants.BLOBS ][ Constants.USER_BLOB ][ Constants.GH_CAS ]

                data = data_to_post()
                ret, result = self.check_pass(user_blob_set, [ zauth, Constants.USER_BLOB, data, cas ],[0])
                oldFile = diff_path + '/old.txt'
                f = open(oldFile,'wb+')
                f.write(data)
                f.close()

                result = user_blob_get(zauth)

                newFile = diff_path + '/new.txt'
                f = open(newFile,'wb+')
                f.write(os.urandom(100))
                f.close()

                cas = result[ Constants.BLOBS ][ Constants.USER_BLOB ][ Constants.GH_CAS ]
                checksum  = diff_data_post(diff_path,oldFile,newFile)
                zauth = AuthSystem.getImpersonatedAuthToken(Constants.ZID) #Impersonated token
                ret, result = self.check_pass(user_blob_patch, [ zauth, Constants.USER_BLOB, "%s/out.zcdiff"%diff_path, cas,checksum ],[0])
                self.assertTrue(ret, msg='Failed to send API request')
                os.system('rm %s/out.zcdiff'%diff_path)
if __name__ == '__main__':
	suite0 = unittest.TestLoader().loadTestsFromTestCase(blob_diff)
        unittest.TextTestRunner(verbosity=99).run(suite0)
	import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='/opt/zynga/greyhound/current/tests/scripts/test/results/blob_delta.html')

Beispiel #14
0
import unittest

def suites():
	suite =unittest.TestSuite()
	suite.addTest(unittest.makeSuite(archive_fetch))
	suite.addTest(unittest.makeSuite(archive_queue_update))
	suite.addTest(unittest.makeSuite(credibility_get))
	suite.addTest(unittest.makeSuite(dau_fetch))
	suite.addTest(unittest.makeSuite(dau_update_class))
	suite.addTest(unittest.makeSuite(fraud_update_class))
	suite.addTest(unittest.makeSuite(history_update))
	suite.addTest(unittest.makeSuite(meta_threshold_get))
	suite.addTest(unittest.makeSuite(payments_get_class))
	suite.addTest(unittest.makeSuite(reputation_get))
	suite.addTest(unittest.makeSuite(reputation_update))
	suite.addTest(unittest.makeSuite(thresholds_fetch))
	suite.addTest(unittest.makeSuite(thresholds_update))
	suite.addTest(unittest.makeSuite(archive_blob))
	suite.addTest(unittest.makeSuite(revert_blob))
	suite.addTest(unittest.makeSuite(blob_delete_class))
	suite.addTest(unittest.makeSuite(golden_update_class))
	suite.addTest(unittest.makeSuite(history_get_class))
	suite.addTest(unittest.makeSuite(golden_revert_class))
	return suite

if __name__ == '__main__':
	import testoob
	from testoob.reporting import HTMLReporter
	testoob.main(html='internal.html')
	unittest.TextTestRunner(verbosity=99).run(suites())
Beispiel #15
0
	def testRetrieveRecipeBasedOnID(self):
		pass
        
	

if __name__ == '__main__':
        
	unittest.main()

	
        suite0 = unittest.TestLoader().loadTestsFromTestCase(MyReqTests)
        unittest.TextTestRunner(verbosity=99).run(suite0)

        import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='D:\\PI2.2Iteration\\PythonRestClientRequest\\restRequests.html',xml='D:\\PI2.2Iteration\\PythonRestClientRequest\\restRequests.xml')
        #testoob.main(suite0)


	"""
	suite.addTests([
			unittest.TestLoader().loadTestsFromTestCase(cMSHParseTest),
			unittest.TestLoader().loadTestsFromTestCase(dPIDParseTest),
			unittest.TestLoader().loadTestsFromTestCase(ePVParseTest),
			unittest.TestLoader().loadTestsFromTestCase(fEVNParseTest),
			])

        """


        """
Beispiel #16
0
import unittest
import testoob
from mqs_auth import mqs_auth
from mqs_graph_auth import mqs_graph_auth
from mqs_graph_testcases import mqs_graph_testcases
from mqs_meta_testcases import mqs_meta_testcases

def suite():
	suite = unittest.TestSuite()
	suite.addTests(unittest.makeSuite(mqs_auth))
	suite.addTests(unittest.makeSuite(mqs_graph_auth))
	suite.addTests(unittest.makeSuite(mqs_graph_testcases))
	suite.addTests(unittest.makeSuite(mqs_meta_testcases))
	return suite

if __name__ == '__main__':
	import testoob
	suite()
	from testoob.reporting import HTMLReporter
	testoob.main(html='mqs.html', xml='mqs.xml')
Beispiel #17
0
from user_blob_delete import *
from user_blob_revert_golden import *
from user_history_get  import *
from meta_threshold_get import *
from reputation_get import *
from payments_meta_get import *
from reputation_update import * 

def suites():
        suite =unittest.TestSuite()
	suite.addTest(unittest.makeSuite(golden_revert_class))
	suite.addTest(unittest.makeSuite(blob_delete_class))
	suite.addTest(unittest.makeSuite(history_get_class))
	suite.addTest(unittest.makeSuite(meta_threshold_get))
	suite.addTest(unittest.makeSuite(reputation_get))	
	suite.addtest(unittest.makesuite(admin_payments_get_class))
	suite.addtest(unittest.makesuite(admin_reputation_update))


if __name__ == '__main__':
        import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='/opt/zynga/greyhound/current/tests/scripts/test/results/admin_unit.html')




Beispiel #18
0
		for item in self.input[constants.ACSKEY_GOLDEN]:
			if item['type'] == 'new-world':
				found = True
				self.input['golden'].remove(item)
				break
		if not found:
			self.input[constants.ACSKEY_GOLDEN].append({"type": "new-world"})
		ob = self._processTest(self.input)
		runJobAndWait()
		status, ret = ob.checkStorageYaml()
		self.assertTrue(status, msg=ret)"""


	def _processTest(self, data ):
                status, ret = sendRequest(self.url, data)
                self.assertTrue(status, msg=ret)
                obj = compareFiles(self.input)
                return obj

        def _getDataFromServer(self, data):
                status, ret = sendRequest(self.url, data)
                self.assertTrue(status, msg=ret)
                return ret

if __name__ == '__main__':
	#suite0 = unittest.TestLoader().loadTestsFromTestCase(configAdd)
        #unittest.TextTestRunner(verbosity=99).run(suite0)
	import testoob
        from testoob.reporting import HTMLReporter
        testoob.main(html='ConfigAdd.html')
Beispiel #19
0
        mock_frame.f_code.co_filename = abspath("one.py")
        mock_frame.f_lineno = 1000 # out of the range of one.py's lines

        self.failIf( self.coverage._should_cover_frame(mock_frame) )

    def test_single_file_statistics(self):
        coverage_dict = {
            "lines"   : range(10),
            "covered" : range(5)
        }

        result = self.coverage._single_file_statistics(coverage_dict)
        self.assertEqual( 10, result["lines"] )
        self.assertEqual( 5, result["covered"] )
        self.assertEqual( 50, result["percent"] )

class system_tests(CoverageTest):
    "Large-grain tests for Coverage"

    def test_percentage_full(self):
        if not testoob.capabilities.c.settrace:
            testoob.testing.skip("requires sys.settrace")
        if not testoob.capabilities.c.trace_coverage_support(sample.__file__.replace(".pyc", ".py")):
            testoob.testing.skip("requires coverage support from trace")
        self.coverage.runfunc(sample.foo, 5)
        self.assertEqual( 100, self.coverage.total_coverage_percentage() )

if __name__ == "__main__":
    import testoob
    testoob.main()
Beispiel #20
0
# -*- coding: utf-8 -*-

import os
import unittest
import testoob
#import testlib


if __name__ == "__main__":

    testdir = os.path.split(__file__)[0]
    testfiles = [ f[:-3] for f in os.listdir(testdir or '.') \
                 if f.startswith('test_') and f.endswith('.py') ]
    modules = [ __import__(file) for file in testfiles ]
    test_loader = unittest.TestLoader()
    tests = [ test_loader.loadTestsFromModule(module) for module in modules ]
    testoob.main(unittest.TestSuite(tests))