예제 #1
0
파일: base.py 프로젝트: simplymahmoud/qts
 def __init__(self, *args, **kwargs):
     super(BaseTest, self).__init__(*args, **kwargs)
     self.test_config = {}
     for section in config.keys():
         self.test_config[section]={}
         for key in config[section].keys():
             self.test_config[section][key]=config[section][key]
예제 #2
0
    def __init__(self, testname):
        super(TestCase, self).__init__(testname)
        test_configs = {
            SUBSCRIPTION: (VcloudSubscriptionTestConfig().get(), IntegrationSubscriptionTestConfig().get()),
            ONDEMAND: (VcloudOndemandTestConfig().get(), IntegrationOndemandTestConfig().get()),
        }
        if not config:
            raise RuntimeError(
                "Vcloud Service type not defined."
                "To define service type for tests, add one of command line key"
                " to nosetest command: --tc=ondemand: --tc=subscription:"
            )
        if len(config) != 1:
            raise RuntimeError("Config must contain 1 element")
        self.service_type = config.keys()[0]
        service_config = test_configs.get(self.service_type)
        if not service_config:
            raise RuntimeError(
                "Unknown service_type: {0}. Parameter must one of {1}".format(
                    self.service_type, (SUBSCRIPTION, ONDEMAND)
                )
            )
        self.vcloud_config = service_config[0]
        self.test_config = service_config[1]

        if not self.vcloud_config:
            raise RuntimeError("vcloud_config empty")
        if not self.test_config:
            raise RuntimeError("test_config empty")
예제 #3
0
    def __init__(self, testname):
        super(TestCase, self).__init__(testname)
        test_configs = {
            SUBSCRIPTION: (VcloudSubscriptionTestConfig().get(),
                           IntegrationSubscriptionTestConfig().get()),
            ONDEMAND: (VcloudOndemandTestConfig().get(),
                       IntegrationOndemandTestConfig().get())
        }
        if not config:
            raise RuntimeError(
                "Vcloud Service type not defined."
                "To define service type for tests, add one of command line key"
                " to nosetest command: --tc=ondemand: --tc=subscription:")
        if len(config) != 1:
            raise RuntimeError("Config must contain 1 element")
        self.service_type = config.keys()[0]
        service_config = test_configs.get(self.service_type)
        if not service_config:
            raise RuntimeError(
                "Unknown service_type: {0}. Parameter must one of {1}".format(
                    self.service_type, (SUBSCRIPTION, ONDEMAND)))
        self.vcloud_config = service_config[0]
        self.test_config = service_config[1]

        if not self.vcloud_config:
            raise RuntimeError("vcloud_config empty")
        if not self.test_config:
            raise RuntimeError("test_config empty")
        print "\nUsed config: {0}".format(self.service_type)
        self.vca_client = self.get_client()
예제 #4
0
def setup():
    global TESTCONFIG
    global TESTAPP

    ## Tests can alter decl. THis resets everything
    reload(decl)

    # using nose-testconfig we obtain the config dict passed in through the
    # nosetests command line
    from testconfig import config
    ## now "convert" to app-style dict
    TESTCONFIG = convert_config(config)
    initdb(TESTCONFIG)
    cj = cookielib.CookieJar()

    ### Are we running by generating HTTP to fire at webserver
    ### or are we testing wsgi calls?
    if 'HTTPPROXY' in config.keys():
        app = WSGIProxyApp(config['HTTPPROXY'])
        app.debug = True
        TESTAPP = TestApp(app, extra_environ={
                          'REMOTE_ADDR': '1.2.3.4'}, cookiejar=cj)
        set_constants(config['HTTPPROXY'], TESTAPP)
    else:
        app = make_app(TESTCONFIG)
        app.debug = True
        sessioncache.set_config(config)
        TESTAPP = TestApp(app.wsgi_app, cookiejar=cj)
        set_constants("", TESTAPP)
예제 #5
0
def _readBackend():
    s = "backend"
    typ = None

    if s not in config.keys():
        typ = "LOCAL"
#        raise Exception("Key: %s not found in test config" % s)
    elif s not in config[s]:
        raise Exception("Key: %s not found in test config[%s]" % (s, s))
    else:
        typ = config[s][s]

    if typ == "REST":
        return Backend.RestBackend(config[s]["host"], config[s]["port"])
    elif typ == "LOCAL":
        p = os.path.join(env.tmpDir, "localbackend")
        return Backend.LocalBackend(p)
    else:
        raise Exception("unsupported backendtype: %s" % typ)
예제 #6
0
def setup():
    global TESTCONFIG
    global TESTAPP

    # using nose-testconfig we obtain the config dict passed in through the
    # nosetests command line
    from testconfig import config
    ## now "convert" to app-style dict
    TESTCONFIG = convert_config(config)

    if 'HTTPPROXY' in config.keys():
        app = WSGIProxyApp(config['HTTPPROXY'])
        TESTAPP = TestApp(app, extra_environ={'REMOTE_ADDR': '1.2.3.4'})
    else:
        app = make_app(TESTCONFIG)
        app.debug = True
        TESTAPP = TestApp(app.wsgi_app)


    print "Running setup"
    print "cookies", TESTAPP.cookies 
예제 #7
0
def _readBackend():
    s = "backend"
    typ = None

    if s not in config.keys():
        typ = "LOCAL"


#        raise Exception("Key: %s not found in test config" % s)
    elif s not in config[s]:
        raise Exception("Key: %s not found in test config[%s]" % (s, s))
    else:
        typ = config[s][s]

    if typ == "REST":
        return Backend.RestBackend(config[s]["host"], config[s]["port"])
    elif typ == "LOCAL":
        p = os.path.join(env.tmpDir, "localbackend")
        return Backend.LocalBackend(p)
    else:
        raise Exception("unsupported backendtype: %s" % typ)
예제 #8
0
def setup():

    global TESTCONFIG
    global TESTAPP

    # using nose-testconfig we obtain the config dict passed in through the
    # nosetests command line
    from testconfig import config
    ## now "convert" to app-style dict
    TESTCONFIG = convert_config(config)

    # cleardown(TESTCONFIG)
    # initdb(TESTCONFIG)

    if 'HTTPPROXY' in config.keys():
        app = WSGIProxyApp(config['HTTPPROXY'])
        TESTAPP = TestApp(app, extra_environ={'REMOTE_ADDR': '1.2.3.4'})
    else:
#        cleardown(TESTCONFIG)  # use this in setup - via a renaming?
        app = make_app(TESTCONFIG)
        app.debug = True
        TESTAPP = TestApp(app.wsgi_app)
예제 #9
0
def read_config():
    for section in config.keys():
        test_config[section]={}
        for key in config[section].keys():
            test_config[section][key]=config[section][key]