Ejemplo n.º 1
0
def fakeconfighandler_tempdir(monkeypatch, tempfiledir):
    ch = FakeConfighandler(pathscheme='test1')
    #testdir = os.path.join(os.getcwd(), 'tests', 'test_data', 'test_filestructure', 'labfluence_data_testsetup')
    testdir = os.path.join(tempfiledir, '2013_exp_subdir_test')
    monkeypatch.setattr(ch, 'getConfigDir', lambda x: testdir)
    ch.setkey('local_exp_subDir', testdir)
    ch.setkey('local_exp_rootDir', os.path.dirname(testdir))
    return ch
Ejemplo n.º 2
0
def em_with_ch_with_fakeserver():
    confighandler = ExpConfigHandler(pathscheme='test1')
    server = FakeConfluenceServer(autologin=True,
                                  ui=None,
                                  confighandler=confighandler)
    confighandler.Singletons['server'] = server
    em = ExperimentManager(confighandler=confighandler)
    return em, confighandler, server
Ejemplo n.º 3
0
def test_factoryNew():
    ch = ExpConfigHandler(pathscheme='test1')
    wikiserver = ConfluenceXmlRpcServer(confighandler=ch, autologin=True)
    factory = WikiPageFactory(wikiserver, ch)
    expid_index = 1
    expid = ch.get('expid_fmt').format(exp_series_index=expid_index)
    current_datetime = datetime.now()
    fmt_params = dict(expid=expid,
                      exp_titledesc="First test page"+run_random_string,
                      datetime=current_datetime,
                      date=current_datetime)
    newpage = factory.new('exp_page', fmt_params=fmt_params)
Ejemplo n.º 4
0
def test_factoryNew():
    ch = ExpConfigHandler(pathscheme='test1')
    wikiserver = ConfluenceXmlRpcServer(confighandler=ch, autologin=True)
    factory = WikiPageFactory(wikiserver, ch)
    expid_index = 1
    expid = ch.get('expid_fmt').format(exp_series_index=expid_index)
    current_datetime = datetime.now()
    fmt_params = dict(expid=expid,
                      exp_titledesc="First test page" + run_random_string,
                      datetime=current_datetime,
                      date=current_datetime)
    newpage = factory.new('exp_page', fmt_params=fmt_params)
Ejemplo n.º 5
0
def ch_with_server_and_manager():
    ch = FakeConfighandler()
    server = FakeConfluenceServer(confighandler=ch)
    ch.Singletons.setdefault('server', server)
    em = ExperimentManager(ch)
    ch.Singletons.setdefault('experimentmanager', em)
    return ch
Ejemplo n.º 6
0
def em_with_fake_ch_and_patched_server(monkeypatch):
    """
    Returns
        em, confighandler, server
    where em is an experimentmanager with
    fake confighandler and fake server,
    and where the fake server has patched:
    - getChildren
    """
    confighandler = ExpConfigHandler(pathscheme='test1')
    server = FakeConfluenceServer(autologin=True,
                                  ui=None,
                                  confighandler=confighandler)
    confighandler.Singletons['server'] = server
    em = ExperimentManager(confighandler=confighandler)

    def test_pagesummaries(self):
        summaries = [
            {
                'id': '01',
                'space': '~scholer',
                'parentId': '524296',
                'title': 'RS001 Testpage01',
                'url': None,
                'permissions': 0
            },
            {
                'id': '02',
                'space': '~scholer',
                'parentId': '524296',
                'title': 'Testpage02',
                'url': None,
                'permissions': 0
            },
            {
                'id': '03',
                'space': '~scholer',
                'parentId': '524296',
                'title': 'RS003 Testpage03',
                'url': None,
                'permissions': 0
            },
        ]
        return summaries

    monkeypatch.setattr(server, 'getChildren', test_pagesummaries)
    return em, confighandler, server
Ejemplo n.º 7
0
def test_fakeconfighandler_setkey_and_get():
    ch = FakeConfighandler()
    #wiki_exp_root_pageId: '524296'
    assert ch.get('wiki_exp_root_pageId') == '524296'
    assert ch.setkey('wiki_exp_root_pageId', '123456') == 'exp'
    assert ch.get('wiki_exp_root_pageId') == '123456'
    # Non-existing key:
    assert ch.get('non_existing_key_10937') == None
    assert ch.setkey('non_existing_key_10937', '124356') == 'user'
    assert ch.get('non_existing_key_10937') == '124356'
Ejemplo n.º 8
0
def server_fake_ch_and_proxy():
    """
    Creates a testable server object that uses:
    - Fake ServerProxy from xmlrpclib
    - Fake confighandler.
    """
    ch = FakeConfighandler()
    ch.setkey('wiki_url', 'http://10.14.40.245:8090/rpc/xmlrpc')
    #monkeypatch.setattr(model.server, 'login_prompt', lambda **x: ('fakeusername', 'fakepassword'))
    server = ConfluenceXmlRpcServer(autologin=False, confighandler=ch)
    def prompt_mock(**kwargs):
        logger.info("Call to promptForUserPass with kwargs %s intercepted by monkeypatched attribute, returning 'fakeuser', 'fakepassword'", kwargs)
        return 'fakeuser', 'fakepassword'
    # No reason to use monkeypatch on the test object, should be a permanent change:
    server.promptForUserPass = prompt_mock
    fake_proxy = FakeXmlRpcServerProxy('https://some.url')
    server.RpcServer = fake_proxy
    #monkeypatch.setattr(server, 'Logintoken', lambda x: 'avalidtoken23456')
    return server
Ejemplo n.º 9
0
def test_fakeconfighandler_popkey():
    ch = FakeConfighandler()
    # test for existing key:
    #wiki_exp_root_pageId: '524296'
    assert ch.get('wiki_exp_root_pageId') == '524296'
    # The popkey output can only be predicted because we have configs in an OrderedDict.
    assert ch.popkey('wiki_exp_root_pageId') == (None, 'system', None, 'user', '524296', 'exp')
    assert ch.popkey('wiki_exp_root_pageId') == (None, 'system', None, 'user', None, 'exp')
    assert ch.get('wiki_exp_root_pageId') == None
    # test with non-existing key:
    assert ch.get('non_existing_key') == None
    assert ch.popkey('non_existing_key') == (None, 'system', None, 'user', None, 'exp')
    assert ch.get('non_existing_key') == None
Ejemplo n.º 10
0
def test_fakeconfighandler_setdefault_and_get():
    ch = FakeConfighandler()

    # test for existing key:
    #wiki_exp_root_pageId: '524296'
    assert ch.setdefault('wiki_exp_root_pageId', '123456') == '524296'
    assert ch.get('wiki_exp_root_pageId') == '524296'
    # test with non-existing key:
    assert ch.get('non_existing_key') == None
    assert ch.setdefault('non_existing_key', '123456') == '123456'
    assert ch.get('non_existing_key') == '123456'
Ejemplo n.º 11
0
def fakeconfighandler(monkeypatch, tempfiledir):
    ch = FakeConfighandler(pathscheme='test1')
    #testdir = os.path.join(os.getcwd(), 'tests', 'test_data', 'test_filestructure', 'labfluence_data_testsetup')
    testdir = os.path.join(tempfiledir, '2013_exp_subdir_test')
    monkeypatch.setattr(ch, 'getConfigDir', lambda x: testdir)
    ch.setkey('local_exp_subDir', testdir)
    ch.setkey('local_exp_rootDir', os.path.dirname(testdir))
    return ch
Ejemplo n.º 12
0
def test_fakeconfighandler_saveConfigs():
    ch = FakeConfighandler()
    assert ch.saveConfigs() == None
Ejemplo n.º 13
0
        #logging.getLogger("model.experiment_manager").setLevel(logging.DEBUG)
        #logging.getLogger("model.confighandler").setLevel(logging.DEBUG)
        #logging.getLogger("model.confighandler").setLevel(logging.DEBUG)
        logging.getLogger("model.server").setLevel(logging.DEBUG)
        logging.getLogger("model.model_testdoubles.fake_confighandler").setLevel(logging.DEBUG)
        logging.getLogger("model.model_testdoubles.fake_server").setLevel(logging.DEBUG)
        logging.getLogger("tkui.labfluence_tkapp").setLevel(logging.DEBUG)
        logging.getLogger("tkui.labfluence_tkroot").setLevel(logging.DEBUG)
        logging.getLogger("tkui.mainframe").setLevel(logging.DEBUG)
        logging.getLogger(__name__).setLevel(logging.DEBUG)
        logger.debug("Loggers setting to debug level...")

        pathscheme = argsns.pathscheme or 'test1'

        logger.info( "Enabling testing environment..." )
        confighandler = FakeConfighandler(pathscheme=pathscheme)
        # set basedir for exp:
        confighandler.ConfigPaths['exp'] = os.path.join('tests', 'test_data', 'test_filestructure', 'labfluence_data_testsetup', '.labfluence.yml')
        server = FakeConfluenceServer(confighandler=confighandler)

    else:
        logger.debug(" >>>>>> Initiating real confighandler and server... >>>>>>")
        pathscheme = argsns.pathscheme or 'default1'
        confighandler = ExpConfigHandler(pathscheme='default1')
        try:
            logger.debug("Confighandler instantiated, Initiating server... >>>>>>")
            # setting autologin=False during init should defer login attempt...
            server = ConfluenceXmlRpcServer(autologin=False, confighandler=confighandler)
            server._autologin = True
        except socket.error as e:
            logger.error( "Socket error during server init ('%s'). This should not happen; autologin is shielded by try-clause.", e)
Ejemplo n.º 14
0
def fakeconfighandler(monkeypatch):
    ch = FakeConfighandler()
    testdir = os.path.join(os.getcwd(), 'tests', 'test_data', 'test_filestructure', 'labfluence_data_testsetup')
    monkeypatch.setattr(ch, 'getConfigDir', lambda x: testdir)
    return ch
Ejemplo n.º 15
0
def test_unregisterEntryChangeCallback():
    """
    Confighandler's EntryChange callback system provides two routes by which a callback can be invoked:
    1)  ch.invokeEntryChangeCallback() is invoked with a configentry argument. This will invoke all callbacks
        registrered for that configentry (i.e. all ch.EntryChangeCallbacks).
    2)  As a two-step process, where the configentry is first added to ch.ChangedEntriesForCallbacks (set)
        and then, ch.invokeEntryChangeCallback() is invoked without any arguments, which will then call
        ch.invokeEntryChangeCallback() with all configentry from the ChangedEntriesForCallbacks set.
    """

    class testobject(object):
        def __init__(self):
            self.testvar1 = 0
            self.testvar2 = 0
        def increment(self):
            self.testvar1 += 1
        def addition(self, inc):
            self.testvar2 += inc
        def incrementvar(self, var):
            var += 1


    ch = FakeConfighandler()
    to = testobject()
    ch.registerEntryChangeCallback('testentryA', to.increment)
    ch.registerEntryChangeCallback('testentryB', to.addition, (3,) )
    ch.registerEntryChangeCallback('testentryA', to.addition, (10,) )
    assert to.testvar1 == 0
    assert to.testvar2 == 0

    ## Also testing unregisterEntryChangeCallback
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 1
    assert to.testvar2 == 10

    ch.unregisterEntryChangeCallback('testentryA', to.increment)
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 1
    assert to.testvar2 == 20

    ch.unregisterEntryChangeCallback(None, to.addition)
    ch.invokeEntryChangeCallback('testentryA')
    ch.invokeEntryChangeCallback('testentryB')
    assert to.testvar1 == 1
    assert to.testvar2 == 20

    ch.registerEntryChangeCallback('testentryA', to.increment)
    ch.registerEntryChangeCallback('testentryA', to.addition, (3,) )
    ch.invokeEntryChangeCallback('testentryA')
    ch.invokeEntryChangeCallback('testentryB')
    assert to.testvar1 == 2
    assert to.testvar2 == 23

    #ch.registerEntryChangeCallback('testentryA', to.increment, (3,) ) # if this is registrered, it will also be unregistrered by the call below:
    ch.unregisterEntryChangeCallback(None, None, (3,) )
    # now only to.increment should be registrered:
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 3
    assert to.testvar2 == 23

    # Registering and removing based on kwargs:
    ch.registerEntryChangeCallback('testentryA', to.increment, None, {'hello': 'there'} )
    ch.unregisterEntryChangeCallback(kwargs={'hello': 'there'})
    # now only to.increment should be registrered:
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 4
    assert to.testvar2 == 23

    # Removing all for a particular configentry:
    ch.registerEntryChangeCallback('testentryB', to.addition, (4,) )
    ch.unregisterEntryChangeCallback('testentryA')
    #  callbacks should be registrered:
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 4
    assert to.testvar2 == 23
    ch.invokeEntryChangeCallback('testentryB')
    assert to.testvar1 == 4
    assert to.testvar2 == 27

    # Removing all
    ch.unregisterEntryChangeCallback()
    # no callbacks should be registrered:
    ch.invokeEntryChangeCallback('testentryA')
    ch.invokeEntryChangeCallback('testentryB')
    assert to.testvar1 == 4
    assert to.testvar2 == 27
Ejemplo n.º 16
0
def test_registerEntryChangeCallback():
    """
    Confighandler's EntryChange callback system provides two routes by which a callback can be invoked:
    1)  ch.invokeEntryChangeCallback() is invoked with a configentry argument. This will invoke all callbacks
        registrered for that configentry (i.e. all ch.EntryChangeCallbacks).
    2)  As a two-step process, where the configentry is first added to ch.ChangedEntriesForCallbacks (set)
        and then, ch.invokeEntryChangeCallback() is invoked without any arguments, which will then call
        ch.invokeEntryChangeCallback() with all configentry from the ChangedEntriesForCallbacks set.
    """

    class testobject(object):
        def __init__(self):
            self.testvar1 = 0
            self.testvar2 = 0
        def increment(self):
            self.testvar1 += 1
        def addition(self, inc):
            self.testvar2 += inc
        def incrementvar(self, var):
            var += 1


    ch = FakeConfighandler()
    to = testobject()
    ch.registerEntryChangeCallback('testentryA', to.increment)
    ch.registerEntryChangeCallback('testentryB', to.addition, 3)
    assert to.testvar1 == 0
    assert to.testvar2 == 0
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 1
    assert to.testvar2 == 0
    ch.invokeEntryChangeCallback('testentryB')
    assert to.testvar1 == 1
    assert to.testvar2 == 3
    ch.registerEntryChangeCallback('testentryA', to.addition, 10)
    ch.invokeEntryChangeCallback('testentryA')
    assert to.testvar1 == 2
    assert to.testvar2 == 13
    ch.ChangedEntriesForCallbacks.add('testentryA')
    ch.ChangedEntriesForCallbacks.add('testentryB')
    ch.invokeEntryChangeCallback('testentryB')
    assert to.testvar1 == 2
    assert to.testvar2 == 16
    ch.invokeEntryChangeCallback()
    # callbacks for A are invoked, these are to.increment and to.addition(10)
    assert to.testvar1 == 3
    assert to.testvar2 == 26
    ch.ChangedEntriesForCallbacks.add('testentryA')
    ch.ChangedEntriesForCallbacks.add('testentryB')
    ch.invokeEntryChangeCallback()
    # callbacks for both A and B are invoked, these are to.increment and to.addition(10) and to.addition(3)
    assert to.testvar1 == 4
    assert to.testvar2 == 39
    ch.invokeEntryChangeCallback()
    # No callbacks are called, since all elements were cleared from ch.ChangedEntriesForCallbacks
    assert to.testvar1 == 4
    assert to.testvar2 == 39
Ejemplo n.º 17
0
def main():

    ##############################
    ###### Parse arguments: ######
    ##############################

    #argsns = parser.parse_args() # produces a namespace, not a dict.
    argsns = parse_args()

    #######################################
    ### Set up standard logging system ####
    #######################################
    loghandlers = init_logging(argsns, prefix="labfluence_cmd")

    ############################
    #### Set up logging:    ####
    ############################
    #logfmt = "%(levelname)s %(name)s:%(lineno)s %(funcName)s() > %(message)s"
    #try:
    #    loglevel = int(argsns.loglevel)
    #except ValueError:
    #    loglevel = argsns.loglevel.upper()
    ##logfmt = "%(levelname)s:%(name)s: %(funcName)s() :: %(message)s"
    #if argsns.debug is None:
    #    #and 'all' in argsns.debug:
    #    logging.basicConfig(level=loglevel, format=logfmt)
    ## argsns.debug is a list (possibly empty)
    #elif argsns.debug:
    ## argsns.debug is a non-empty list
    #    logging.basicConfig(level=loglevel, format=logfmt)
    #    for mod in argsns.debug:
    #        logger.info("Enabling logging debug messages for module: %s", mod)
    #        logging.getLogger(mod).setLevel(logging.DEBUG)
    #else:
    #    # argsns.debug is an empty list
    #    logging.basicConfig(level=min(logging.DEBUG, loglevel), format=logfmt)
    #logging.getLogger("__main__").setLevel(logging.DEBUG)

    #
    #if argsns.logtofile or True: # always log for now...
    #    # based on http://docs.python.org/2/howto/logging-cookbook.html
    #    if not os.path.exists('logs'):
    #        os.mkdir('logs')
    #    if argsns.testing:
    #        fh = logging.FileHandler('logs/labfluence_cmd_testing.log')
    #    else:
    #        fh = logging.FileHandler('logs/labfluence_cmd_debug.log')
    #    fh.setLevel(logging.DEBUG)
    #    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    #    fh.setFormatter(formatter)
    #    logging.getLogger('').addHandler(fh)  #  logging.root == logging.getLogger('')

    ####################################################################################
    # Set up confighandler, etc (depending on whether testing mode is requested...) ####
    ####################################################################################
    if argsns.testing:
        logging.getLogger(
            "model.model_testdoubles.fake_confighandler").setLevel(
                logging.DEBUG)
        logging.getLogger("model.model_testdoubles.fake_server").setLevel(
            logging.DEBUG)
        logging.getLogger(__name__).setLevel(logging.DEBUG)
        pathscheme = argsns.pathscheme or 'test1'
        logger.info("Enabling testing environment...:")
        confighandler = FakeConfighandler(pathscheme=pathscheme)
        # set basedir for exp:
        confighandler.ConfigPaths['exp'] = os.path.join(
            'tests', 'test_data', 'test_filestructure',
            'labfluence_data_testsetup', '.labfluence.yml')
        confserver = FakeConfluenceServer(confighandler=confighandler)
    else:
        pathscheme = argsns.pathscheme or 'default1'
        confighandler = ExpConfigHandler(pathscheme=pathscheme)
        try:
            confserver = ConfluenceXmlRpcServer(autologin=True,
                                                confighandler=confighandler)
        except socket.error:
            print "This should not happen; autologin is shielded by try-clause. Perhaps network issues?"
            exit(1)

    confighandler.Singletons['server'] = confserver

    # Test if default func is defined after parsing:
    func = getattr(argsns, 'func', None)
    if func:
        logger.debug("Executing function %s with argsns %s", func, argsns)
        ret = func(argsns)
    else:
        logger.error("No func specified...?")
Ejemplo n.º 18
0
def fakeconfighandler():
    return FakeConfighandler()
Ejemplo n.º 19
0
def fakeconfighandler():
    ch = FakeConfighandler(pathscheme='test1')
    server = FakeConfluenceServer(autologin=True, ui=None, confighandler=ch)
    ch.Singletons['server'] = server
    return ch
Ejemplo n.º 20
0
def fakeconfighandler():
    ch = FakeConfighandler(pathscheme='test1')
    server = FakeConfluenceServer(autologin=True, ui=None, confighandler=ch)
    ch.Singletons['server'] = server
    return ch
Ejemplo n.º 21
0
    ####################################################################################
    if argsns.testing:
        # Other modules should be enabled with --debug <modules>.
        logging.getLogger("model.server").setLevel(logging.DEBUG)
        logging.getLogger("model.limspage").setLevel(logging.DEBUG)
        logging.getLogger("model.page").setLevel(logging.DEBUG)
        logging.getLogger("model.model_testdoubles.fake_confighandler").setLevel(logging.DEBUG)
        logging.getLogger("model.model_testdoubles.fake_server").setLevel(logging.DEBUG)
        logging.getLogger("tkui.lims_app").setLevel(logging.DEBUG)
        logging.getLogger("tkui.lims_tkroot").setLevel(logging.DEBUG)
        #logging.getLogger("tkui.views.lims_frame").setLevel(logging.DEBUG)
        logging.getLogger(__name__).setLevel(logging.DEBUG)
        logger.debug("Loggers setting to debug level...")
        pathscheme = argsns.pathscheme or 'test1'
        logger.info( "Enabling testing environment..." )
        confighandler = FakeConfighandler(pathscheme=pathscheme)
        # set basedir for exp:
        confighandler.ConfigPaths['exp'] = os.path.join('tests', 'test_data', 'test_filestructure', 'labfluence_data_testsetup', '.labfluence.yml')
        server = FakeConfluenceServer(confighandler=confighandler)
    else:
        logger.debug(">>>>>> Initiating real confighandler and server... >>>>>>")
        pathscheme = argsns.pathscheme or 'default1'
        confighandler = ExpConfigHandler(pathscheme=argsns.pathscheme)
        logger.debug("<<<<< Confighandler instantiated, Initiating server... >>>>>")
        # setting autologin=False during init should defer login attempt...
        server = ConfluenceXmlRpcServer(autologin=False, confighandler=confighandler)
        server._autologin = True

    # Init server and application:
    confighandler.Singletons['server'] = server
    logger.debug("<<<<< Server instantiated, starting LimsApp... >>>>>")
Ejemplo n.º 22
0
def test_fakeconfighandler_configpaths_and_configs():
    ch = FakeConfighandler()
    assert ch.ConfigPaths['system'] == None
    assert ch.ConfigPaths['user'] == None
    assert ch.ConfigPaths['exp'] == None
Ejemplo n.º 23
0
def test_singleton_logic():
    ch = FakeConfighandler()
    test_singleton = datetime.now()
    assert ch.setSingleton('mydate', test_singleton) == None
    assert ch.getSingleton('mydate') == test_singleton
Ejemplo n.º 24
0
def main():

    ##############################
    ###### Parse arguments: ######
    ##############################

    #argsns = parser.parse_args() # produces a namespace, not a dict.
    argsns = parse_args()

    #######################################
    ### Set up standard logging system ####
    #######################################
    loghandlers = init_logging(argsns, prefix="labfluence_cmd")


    ############################
    #### Set up logging:    ####
    ############################
    #logfmt = "%(levelname)s %(name)s:%(lineno)s %(funcName)s() > %(message)s"
    #try:
    #    loglevel = int(argsns.loglevel)
    #except ValueError:
    #    loglevel = argsns.loglevel.upper()
    ##logfmt = "%(levelname)s:%(name)s: %(funcName)s() :: %(message)s"
    #if argsns.debug is None:
    #    #and 'all' in argsns.debug:
    #    logging.basicConfig(level=loglevel, format=logfmt)
    ## argsns.debug is a list (possibly empty)
    #elif argsns.debug:
    ## argsns.debug is a non-empty list
    #    logging.basicConfig(level=loglevel, format=logfmt)
    #    for mod in argsns.debug:
    #        logger.info("Enabling logging debug messages for module: %s", mod)
    #        logging.getLogger(mod).setLevel(logging.DEBUG)
    #else:
    #    # argsns.debug is an empty list
    #    logging.basicConfig(level=min(logging.DEBUG, loglevel), format=logfmt)
    #logging.getLogger("__main__").setLevel(logging.DEBUG)

    #
    #if argsns.logtofile or True: # always log for now...
    #    # based on http://docs.python.org/2/howto/logging-cookbook.html
    #    if not os.path.exists('logs'):
    #        os.mkdir('logs')
    #    if argsns.testing:
    #        fh = logging.FileHandler('logs/labfluence_cmd_testing.log')
    #    else:
    #        fh = logging.FileHandler('logs/labfluence_cmd_debug.log')
    #    fh.setLevel(logging.DEBUG)
    #    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    #    fh.setFormatter(formatter)
    #    logging.getLogger('').addHandler(fh)  #  logging.root == logging.getLogger('')


    ####################################################################################
    # Set up confighandler, etc (depending on whether testing mode is requested...) ####
    ####################################################################################
    if argsns.testing:
        logging.getLogger("model.model_testdoubles.fake_confighandler").setLevel(logging.DEBUG)
        logging.getLogger("model.model_testdoubles.fake_server").setLevel(logging.DEBUG)
        logging.getLogger(__name__).setLevel(logging.DEBUG)
        pathscheme = argsns.pathscheme or 'test1'
        logger.info( "Enabling testing environment...:" )
        confighandler = FakeConfighandler(pathscheme=pathscheme)
        # set basedir for exp:
        confighandler.ConfigPaths['exp'] = os.path.join('tests', 'test_data', 'test_filestructure', 'labfluence_data_testsetup', '.labfluence.yml')
        confserver = FakeConfluenceServer(confighandler=confighandler)
    else:
        pathscheme = argsns.pathscheme or 'default1'
        confighandler = ExpConfigHandler(pathscheme=pathscheme)
        try:
            confserver = ConfluenceXmlRpcServer(autologin=True, confighandler=confighandler)
        except socket.error:
            print "This should not happen; autologin is shielded by try-clause. Perhaps network issues?"
            exit(1)

    confighandler.Singletons['server'] = confserver


    # Test if default func is defined after parsing:
    func = getattr(argsns, 'func', None)
    if func:
        logger.debug("Executing function %s with argsns %s", func, argsns)
        ret = func(argsns)
    else:
        logger.error("No func specified...?")