本文整理汇总了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
示例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 = ''
#.........这里部分代码省略.........
示例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):
#.........这里部分代码省略.........