当前位置: 首页>>代码示例>>Python>>正文


Python BlitzGateway.getConfigService方法代码示例

本文整理汇总了Python中omero.gateway.BlitzGateway.getConfigService方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.getConfigService方法的具体用法?Python BlitzGateway.getConfigService怎么用?Python BlitzGateway.getConfigService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在omero.gateway.BlitzGateway的用法示例。


在下文中一共展示了BlitzGateway.getConfigService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestConfig

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getConfigService [as 别名]
class TestConfig(lib.ITest):

    def setup_method(self, method):
        # prepare session
        self.r = RequestFactory().get('/rand')
        middleware = SessionMiddleware()
        middleware.process_request(self.r)
        self.r.session.save()
        self.rs = self.root.sf.getConfigService()
        self.conn = BlitzGateway(client_obj=self.new_client())

    def teardown_method(self, method):
        self.conn.seppuku()
        self.r.session.flush()

    def testDefaultConfig(self):
        """ Test loading default config """
        deprecated = [
            'omero.client.ui.menu.dropdown.everyone',
            'omero.client.ui.menu.dropdown.leaders',
            'omero.client.ui.menu.dropdown.colleagues'
        ]
        default = self.rs.getClientConfigDefaults()
        login_required(default_view).load_server_settings(self.conn, self.r)
        s = {"omero": {"client": self.r.session.get('server_settings', {})}}
        ss = self.r.session['server_settings']
        # assert if alias gives the same value as deprecated
        # rather then ${property}
        for d in deprecated:
            ds = d.split(".")
            assert ss['ui']['menu']['dropdown'][ds[-1]]['label'] == default[d]
            # workaround for alias as getClientConfigDefaults returns
            # ${property} rather then value
            assert ss['ui']['menu']['dropdown'][ds[-1]]['label'] == \
                self.conn.getConfigService().getConfigValue(
                    default['%s.label' % d][2:-1])

        # compare keys in default and config loaded by decorator
        a = filter(lambda x: x not in (
            set(default.keys()) - set(deprecated)),
            set(flattenProperties(s).keys()))
        assert a == ['omero.client.email']

    def testDefaultConfigConversion(self):
        default = self.rs.getClientConfigDefaults()

        # bool
        key1 = 'omero.client.ui.tree.orphans.enabled'
        self.rs.setConfigValue(key1, default[key1])

        key11 = 'omero.client.ui.tree.orphans.name'
        self.rs.setConfigValue(key11, default[key11])

        # digit
        key2 = 'omero.client.viewer.roi_limit'
        self.rs.setConfigValue(key2, default[key2])

        login_required(default_view).load_server_settings(self.conn, self.r)
        ss = self.r.session['server_settings']

        assert isinstance(ss['ui']['tree']['orphans']['enabled'], bool)
        assert ss['ui']['tree']['orphans']['enabled'] == bool(default[key1])

        assert isinstance(ss['ui']['tree']['orphans']['name'], str)
        assert ss['ui']['tree']['orphans']['name'] == default[key11]

        assert isinstance(ss['viewer']['roi_limit'], int)
        assert ss['viewer']['roi_limit'] == json.loads(default[key2])

    @pytest.mark.parametrize("prop", ["colleagues", "leaders", "everyone",
                                      "colleagues.label", "leaders.label",
                                      "everyone.label"])
    @pytest.mark.parametrize("label", ["foo"])
    def testUpgradeDropdownMenuConfig(self, prop, label):
        """ Test if alias loads deprecated property value """
        d = self.rs.getClientConfigDefaults()
        key = "omero.client.ui.menu.dropdown.%s" % prop
        try:
            self.rs.setConfigValue(key, label)
            # test load_server_settings directly
            login_required(default_view).load_server_settings(
                self.conn, self.r)
            s = self.r.session.get('server_settings', {})
            prop = prop.replace(".label", "")
            assert s['ui']['menu']['dropdown'][prop]['label'] == label
        finally:
            self.rs.setConfigValue(key, d[key])

    def mock_getClientSettings(self, monkeypatch, default):
        def get_clientSettings(*args, **kwargs):
            not_exist = [
                'omero.client.ui.menu.dropdown.everyone.label',
                'omero.client.ui.menu.dropdown.leaders.label',
                'omero.client.ui.menu.dropdown.colleagues.label',
                'omero.client.ui.tree.orphans.enabled',
                'omero.client.viewer.initial_zoom_level'
            ]
            for n in not_exist:
                if n in default:
                    del default[n]
#.........这里部分代码省略.........
开发者ID:kennethgillen,项目名称:openmicroscopy,代码行数:103,代码来源:test_config.py


注:本文中的omero.gateway.BlitzGateway.getConfigService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。