Пример #1
0
    def setUp(self):

        super(CosmoTest, self).setUp()

        reactor.useRealTime()

        self.useSSL = False
        #self.useSSL = True
        self.username = "******"
        self.password = "******"
        #self.host = "localhost"
        #self.username = "******"
        #self.password = "******"
        #self.username = "******"
        #self.password = "******"
        self.host = "cosmo-demo.osafoundation.org"
        self.port = 8080
        #self.port = 443
        self.path = "/home/%s" % (self.username, )
        self.url = "http://" + self.host + ":" + str(self.port) + self.path

        self.server = ServerHandle(self.host, self.port, self.username,
                                   self.password, self.useSSL)

        global ACCOUNT_CREATED
        if not ACCOUNT_CREATED:

            ACCOUNT_CREATED = True

            testHandle = ServerHandle(self.host, self.port, "root", "cosmo",
                                      False)
            xmlCreateAccount = """<?xml version="1.0" encoding="utf-8" ?> 
        <user xmlns="http://osafoundation.org/cosmo">
          <username>%s</username>
          <password>%s</password>
          <firstName>Tommy</firstName>
          <lastName>Tester</lastName>
          <email>%[email protected]</email>
        </user>
        """ % (self.username, self.password, self.username)

            body = xmlCreateAccount.encode("utf-8")

            headers = {'content-type': 'text/xml', 'connection': 'close'}

            print "Creating user account %s" % self.username

            req = Request('PUT', '/api/user/%s' % self.username, headers, body)
            req.timeout = 45.0
            response = reactor.waitUntil(testHandle.factory.addRequest(req),
                                         45.0)

            if response.status == 201:
                print "Created user account %s" % self.username
            elif response.status == 204:
                print "WARNING: Account %s already exists." % self.username
            elif response.status == 401:
                print "ERROR: Authorization error. Check username and password."
            else:
                print "ERROR %s. Unknown error" % response.status
Пример #2
0
    def setUp(self):

        super(CosmoTest, self).setUp()
        
        reactor.useRealTime()
        
        self.useSSL = False
        #self.useSSL = True
        self.username = "******"
        self.password = "******"
        #self.host = "localhost"
        #self.username = "******"
        #self.password = "******"
        #self.username = "******"
        #self.password = "******"
        self.host = "cosmo-demo.osafoundation.org"
        self.port = 8080
        #self.port = 443
        self.path = "/home/%s" % (self.username,)
        self.url = "http://" + self.host + ":" + str(self.port) + self.path
        
        self.server = ServerHandle(self.host, self.port, self.username,
                                   self.password, self.useSSL)
                                   
        global ACCOUNT_CREATED
        if not ACCOUNT_CREATED:
                
            ACCOUNT_CREATED = True

            testHandle = ServerHandle(self.host, self.port, "root", "cosmo", False)
            xmlCreateAccount = """<?xml version="1.0" encoding="utf-8" ?> 
        <user xmlns="http://osafoundation.org/cosmo">
          <username>%s</username>
          <password>%s</password>
          <firstName>Tommy</firstName>
          <lastName>Tester</lastName>
          <email>%[email protected]</email>
        </user>
        """ % (self.username, self.password, self.username)

            body = xmlCreateAccount.encode("utf-8")
            
            headers = { 'content-type': 'text/xml', 'connection': 'close' }
            
            print "Creating user account %s" % self.username

            req = Request('PUT', '/api/user/%s' % self.username, headers, body)
            req.timeout = 45.0
            response = reactor.waitUntil(testHandle.factory.addRequest(req), 45.0)

            if response.status == 201:
                print "Created user account %s" % self.username
            elif response.status == 204:
                print "WARNING: Account %s already exists." % self.username
            elif response.status == 401:
                print "ERROR: Authorization error. Check username and password."
            else:
                print "ERROR %s. Unknown error" % response.status
Пример #3
0
 def testModeChanges_1(self):
     reactor.useRealTime()
     reactor.useRealTime()
     reactor.useRealTime()
     self.assertRaises(AssertionError, reactor.useSimulatedTime)
     self.failIf(self.isSimulated())
Пример #4
0
    def testRealTimeIsReal(self):
        reactor.useRealTime()
        self.failIf(self.isSimulated())

        # shouldn't let us set the time, either
        self.assertRaises(AssertionError, lambda: reactor.setTime(0))
Пример #5
0
    def testRealTimeIsReal(self):
        reactor.useRealTime()
        self.failIf(self.isSimulated())

        # shouldn't let us set the time, either
        self.assertRaises(AssertionError, lambda: reactor.setTime(0))
Пример #6
0
 def testModeChanges_1(self):
     reactor.useRealTime()
     reactor.useRealTime()
     reactor.useRealTime()
     self.assertRaises(AssertionError, reactor.useSimulatedTime)
     self.failIf(self.isSimulated())