Beispiel #1
0
 def testA(self):
     """object driven connection via initialiseCouch method"""
     
     class Thingy(object):
         """misc object with couch access attrs"""
         def __init__(self):
             self.couchdb = None
             self.database = None
             self.url = None
     
         @CouchUtils.connectToCouch
         def __call__(self):
             return True
         
     couchThingy = Thingy()
     
     # test throws with everything None
     self.assertRaises(CouchUtils.CouchConnectionError, CouchUtils.initialiseCouch, couchThingy)
     couchThingy.url = self.testInit.couchUrl
     self.assertRaises(CouchUtils.CouchConnectionError, CouchUtils.initialiseCouch, couchThingy)
     couchThingy.database = self.testInit.couchDbName
     
     try:
         CouchUtils.initialiseCouch(couchThingy)
     except Exception, ex:
         msg = "Error initialising couch client for test object:\n %s " % str(ex)
         self.fail(msg)
Beispiel #2
0
    def testA(self):
        """object driven connection via initialiseCouch method"""

        class Thingy(object):
            """misc object with couch access attrs"""
            def __init__(self):
                self.couchdb = None
                self.database = None
                self.url = None

            @CouchUtils.connectToCouch
            def __call__(self):
                return True

        couchThingy = Thingy()

        # test throws with everything None
        self.assertRaises(CouchUtils.CouchConnectionError, CouchUtils.initialiseCouch, couchThingy)
        couchThingy.url = self.testInit.couchUrl
        self.assertRaises(CouchUtils.CouchConnectionError, CouchUtils.initialiseCouch, couchThingy)
        couchThingy.database = self.testInit.couchDbName

        try:
            CouchUtils.initialiseCouch(couchThingy)
        except Exception, ex:
            msg = "Error initialising couch client for test object:\n %s " % str(ex)
            self.fail(msg)
Beispiel #3
0
    def testA(self):
        """object driven connection via initialiseCouch method"""
        class Thingy(object):
            """misc object with couch access attrs"""
            def __init__(self):
                self.couchdb = None
                self.database = None
                self.url = None

            @CouchUtils.connectToCouch
            def __call__(self):
                return True

        couchThingy = Thingy()

        # test throws with everything None
        self.assertRaises(CouchUtils.CouchConnectionError,
                          CouchUtils.initialiseCouch, couchThingy)
        couchThingy.url = self.testInit.couchUrl
        self.assertRaises(CouchUtils.CouchConnectionError,
                          CouchUtils.initialiseCouch, couchThingy)
        couchThingy.database = self.testInit.couchDbName

        try:
            CouchUtils.initialiseCouch(couchThingy)
        except Exception as ex:
            msg = "Error initialising couch client for test object:\n %s " % str(
                ex)
            self.fail(msg)

        self.assertTrue(couchThingy.couchdb != None)
        # test decorator on already connected object
        try:
            couchThingy()
        except Exception as ex:
            msg = "Error invoking connectToCouch decorator:\n %s" % str(msg)
            self.fail(msg)

        newCouchThingy = Thingy()
        newCouchThingy.database = self.testInit.couchDbName
        newCouchThingy.url = self.testInit.couchUrl
        # 2nd call will make sure full connection is called
        try:
            newCouchThingy()
        except Exception as ex:
            msg = "Error invoking connectToCouch decorator:\n %s" % str(msg)
            self.fail(msg)
        self.assertTrue(newCouchThingy != None)
Beispiel #4
0
    def testA(self):
        """object driven connection via initialiseCouch method"""

        class Thingy(object):
            """misc object with couch access attrs"""

            def __init__(self):
                self.couchdb = None
                self.database = None
                self.url = None

            @CouchUtils.connectToCouch
            def __call__(self):
                return True

        couchThingy = Thingy()

        # test throws with everything None
        self.assertRaises(CouchUtils.CouchConnectionError, CouchUtils.initialiseCouch, couchThingy)
        couchThingy.url = self.testInit.couchUrl
        self.assertRaises(CouchUtils.CouchConnectionError, CouchUtils.initialiseCouch, couchThingy)
        couchThingy.database = self.testInit.couchDbName

        try:
            CouchUtils.initialiseCouch(couchThingy)
        except Exception as ex:
            msg = "Error initialising couch client for test object:\n %s " % str(ex)
            self.fail(msg)

        self.failUnless(couchThingy.couchdb != None)
        # test decorator on already connected object
        try:
            couchThingy()
        except Exception as ex:
            msg = "Error invoking connectToCouch decorator:\n %s" % str(msg)
            self.fail(msg)

        newCouchThingy = Thingy()
        newCouchThingy.database = self.testInit.couchDbName
        newCouchThingy.url = self.testInit.couchUrl
        # 2nd call will make sure full connection is called
        try:
            newCouchThingy()
        except Exception as ex:
            msg = "Error invoking connectToCouch decorator:\n %s" % str(msg)
            self.fail(msg)
        self.failUnless(newCouchThingy != None)