import unittest

class Test(unittest.TestCase):

    def setUp(self):
        self.seq = range(10)

    #def test_shuffle(self):
    #    # make sure the shuffled sequence does not lose any elements
    #    random.shuffle(self.seq)
    #    self.seq.sort()
    #    self.assertEqual(self.seq, range(10))

    #def test_choice(self):
    #    element = random.choice(self.seq)
    #    self.assertTrue(element in self.seq)

    #def test_sample(self):
    #    self.assertRaises(ValueError, random.sample, self.seq, 20)
    #    for element in random.sample(self.seq, 5):
    #        self.assertTrue(element in self.seq)

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

import unittest, xmlrpclib, couchdb
from ConfigParser import SafeConfigParser

class Test(unittest.TestCase):

    def setUp(self):
        self.cfg = SafeConfigParser()
        self.cfg.read(('rpc_client.ini', '../stats/basicStats.ini'))
        host = self.cfg.get('connection', 'server')
        port = self.cfg.getint('connection', 'port')
        connString = 'http://%s:%i' % (host, port)
        self.sp = xmlrpclib.ServerProxy(connString)
        self.projName = 'test_project_abracadabra'


    def test_projectExists(self):
        self.assertFalse( self.sp.projectExists(self.projName) )
        
        
    def test_createAndDeleteProject(self):
        self.assertFalse( self.sp.projectExists(self.projName) )
        self.sp.createProject(self.projName)
        self.assertTrue( self.sp.projectExists(self.projName) )
        self.sp.deleteProject(self.projName)
        self.assertFalse( self.sp.projectExists(self.projName) )
        
    def test_createViews(self):
        if self.sp.projectExists(self.projName):
            self.sp.createProject(self.projName)
        self.assertFalse( self.sp.projectExists(self.projName) )
        self.sp.createProject(self.projName)
        
        server = couchdb.Server(self.cfg.get('couchdb', 'dbaddress'))
        db = server[self.projName]
        self.assertTrue('_design/manage' in db)
        self.assertTrue('_design/basicStats' in db)
        self.assertTrue('jobs' in db['_design/manage']['views'])
        self.assertTrue('addCar' in db['_design/basicStats']['views'])
        self.assertTrue('deleteCar' in db['_design/basicStats']['views'])
        
        self.sp.deleteProject(self.projName)
        self.assertFalse( self.sp.projectExists(self.projName) )
    

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

Make some simple unit test for RPC server.
Make some simple unit test for RPC server.
