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


Python ProductEnvironment.enable_component方法代码示例

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


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

示例1: ProductResourceTestCase

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import enable_component [as 别名]
class ProductResourceTestCase(MultiproductTestCase):
    def setUp(self):
        self._mp_setup()
        self.global_env = self.env
        self._load_product_from_data(self.global_env, u'xü')

        self.env = ProductEnvironment(self.global_env, self.default_product)
        self.env1 = ProductEnvironment(self.global_env, u'xü')

        self._load_default_data(self.global_env)
        self._load_default_data(self.env1)

        # Enable product system component in product context
        self.env.enable_component(MultiProductSystem)

    def tearDown(self):
        self.global_env.reset_db()
        self.global_env = self.env = None
开发者ID:mohsadki,项目名称:dargest,代码行数:20,代码来源:resource.py

示例2: ProductModuleTestCase

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import enable_component [as 别名]
class ProductModuleTestCase(RequestHandlerTestCase):
    def setUp(self):
        self._mp_setup()
        self.global_env = self.env
        self.env = ProductEnvironment(self.global_env, self.default_product)

        self.global_env.enable_component(TestRequestSpy)
        self.env.enable_component(TestRequestSpy)
        TestRequestSpy(self.global_env).testMatch = self._assert_product_match
        PermissionSystem(self.global_env).grant_permission('testuser', 'PRODUCT_CREATE')
        PermissionSystem(self.global_env).grant_permission('testuser', 'PRODUCT_VIEW')
        PermissionSystem(self.global_env).grant_permission('testuser', 'PRODUCT_MODIFY')

    def tearDown(self):
        self.global_env.reset_db()
        self.env = self.global_env = None

    expectedPrefix = None
    expectedPathInfo = None

    def _assert_product_match(self, req, handler):
        self.assertIs(ProductModule(self.global_env), handler)
        self.assertEqual(self.expectedPrefix, req.args['productid'],
                         "Unexpected product prefix")
        self.assertEqual(self.expectedPathInfo, req.args['pathinfo'],
                         "Unexpected sub path")

    def test_product_list(self):
        spy = self.global_env[TestRequestSpy]
        self.assertIsNot(None, spy)

        req = self._get_request_obj(self.global_env)
        req.authname = 'testuser'
        req.environ['PATH_INFO'] = '/products'

        mps = MultiProductSystem(self.global_env)
        def assert_product_list(req, template, data, content_type):
            self.assertEquals('product_list.html', template)
            self.assertIs(None, content_type)
            self.assertEquals([mps.default_product_prefix,
                               self.default_product],
                              [p.prefix for p in data.get('products')])
            self.assertTrue('context' in data)
            ctx = data['context']
            self.assertEquals('product', ctx.resource.realm)
            self.assertEquals(None, ctx.resource.id)

        spy.testProcessing = assert_product_list
        with self.assertRaises(RequestDone):
            self._dispatch(req, self.global_env)

    def test_product_new(self):
        spy = self.global_env[TestRequestSpy]
        self.assertIsNot(None, spy)

        req = self._get_request_obj(self.global_env)
        req.authname = 'testuser'
        req.environ['PATH_INFO'] = '/products'
        req.environ['QUERY_STRING'] = 'action=new'

        def assert_product_new(req, template, data, content_type):
            self.assertEquals('product_edit.html', template)
            self.assertIs(None, content_type)
            self.assertFalse('products' in data)
            self.assertTrue('context' in data)
            ctx = data['context']
            self.assertEquals('product', ctx.resource.realm)
            self.assertEquals(None, ctx.resource.id)

        spy.testProcessing = assert_product_new
        with self.assertRaises(RequestDone):
            self._dispatch(req, self.global_env)

    def test_product_view(self):
        spy = self.global_env[TestRequestSpy]
        self.assertIsNot(None, spy)

        def assert_product_view(req, template, data, content_type):
            self.assertEquals('product_view.html', template)
            self.assertIs(None, content_type)
            self.assertFalse('products' in data)

            self.assertTrue('context' in data)
            ctx = data['context']
            self.assertEquals('product', ctx.resource.realm)
            self.assertEquals(real_prefix, ctx.resource.id)

            self.assertTrue('product' in data)
            self.assertEquals(real_prefix, data['product'].prefix)

        spy.testProcessing = assert_product_view

        # Existing product
        req = self._get_request_obj(self.global_env)
        req.authname = 'testuser'
        req.environ['PATH_INFO'] = '/products/%s' % (self.default_product,)

        real_prefix = self.default_product
        self.expectedPrefix = self.default_product
        self.expectedPathInfo = ''
#.........这里部分代码省略.........
开发者ID:mohsadki,项目名称:dargest,代码行数:103,代码来源:web_ui.py

示例3: ProductModuleTestCase

# 需要导入模块: from multiproduct.env import ProductEnvironment [as 别名]
# 或者: from multiproduct.env.ProductEnvironment import enable_component [as 别名]
class ProductModuleTestCase(RequestHandlerTestCase):
    def setUp(self):
        self._mp_setup()
        self.global_env = self.env
        self.env = ProductEnvironment(self.global_env, self.default_product)

        self.global_env.enable_component(TestRequestSpy)
        self.env.enable_component(TestRequestSpy)
        TestRequestSpy(self.global_env).testMatch = self._assert_product_match
        PermissionSystem(self.global_env).grant_permission("testuser", "PRODUCT_CREATE")
        PermissionSystem(self.global_env).grant_permission("testuser", "PRODUCT_VIEW")
        PermissionSystem(self.global_env).grant_permission("testuser", "PRODUCT_MODIFY")

    def tearDown(self):
        self.global_env.reset_db()
        self.env = self.global_env = None

    expectedPrefix = None
    expectedPathInfo = None

    def _assert_product_match(self, req, handler):
        self.assertIs(ProductModule(self.global_env), handler)
        self.assertEqual(self.expectedPrefix, req.args["productid"], "Unexpected product prefix")
        self.assertEqual(self.expectedPathInfo, req.args["pathinfo"], "Unexpected sub path")

    def test_product_list(self):
        spy = self.global_env[TestRequestSpy]
        self.assertIsNot(None, spy)

        req = self._get_request_obj(self.global_env)
        req.authname = "testuser"
        req.environ["PATH_INFO"] = "/products"

        mps = MultiProductSystem(self.global_env)

        def assert_product_list(req, template, data, content_type):
            self.assertEquals("product_list.html", template)
            self.assertIs(None, content_type)
            self.assertEquals(
                [mps.default_product_prefix, self.default_product], [p.prefix for p in data.get("products")]
            )
            self.assertTrue("context" in data)
            ctx = data["context"]
            self.assertEquals("product", ctx.resource.realm)
            self.assertEquals(None, ctx.resource.id)

        spy.testProcessing = assert_product_list
        with self.assertRaises(RequestDone):
            self._dispatch(req, self.global_env)

    def test_product_new(self):
        spy = self.global_env[TestRequestSpy]
        self.assertIsNot(None, spy)

        req = self._get_request_obj(self.global_env)
        req.authname = "testuser"
        req.environ["PATH_INFO"] = "/products"
        req.environ["QUERY_STRING"] = "action=new"

        def assert_product_new(req, template, data, content_type):
            self.assertEquals("product_edit.html", template)
            self.assertIs(None, content_type)
            self.assertFalse("products" in data)
            self.assertTrue("context" in data)
            ctx = data["context"]
            self.assertEquals("product", ctx.resource.realm)
            self.assertEquals(None, ctx.resource.id)

        spy.testProcessing = assert_product_new
        with self.assertRaises(RequestDone):
            self._dispatch(req, self.global_env)

    def test_product_view(self):
        spy = self.global_env[TestRequestSpy]
        self.assertIsNot(None, spy)

        def assert_product_view(req, template, data, content_type):
            self.assertEquals("product_view.html", template)
            self.assertIs(None, content_type)
            self.assertFalse("products" in data)

            self.assertTrue("context" in data)
            ctx = data["context"]
            self.assertEquals("product", ctx.resource.realm)
            self.assertEquals(real_prefix, ctx.resource.id)

            self.assertTrue("product" in data)
            self.assertEquals(real_prefix, data["product"].prefix)

        spy.testProcessing = assert_product_view

        # Existing product
        req = self._get_request_obj(self.global_env)
        req.authname = "testuser"
        req.environ["PATH_INFO"] = "/products/%s" % (self.default_product,)

        real_prefix = self.default_product
        self.expectedPrefix = self.default_product
        self.expectedPathInfo = ""
        with self.assertRaises(RequestDone):
#.........这里部分代码省略.........
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:103,代码来源:web_ui.py


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