本文整理匯總了Python中shop.views.product.ProductDetailView.get_template_names方法的典型用法代碼示例。如果您正苦於以下問題:Python ProductDetailView.get_template_names方法的具體用法?Python ProductDetailView.get_template_names怎麽用?Python ProductDetailView.get_template_names使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類shop.views.product.ProductDetailView
的用法示例。
在下文中一共展示了ProductDetailView.get_template_names方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ProductDetailViewTestCase
# 需要導入模塊: from shop.views.product import ProductDetailView [as 別名]
# 或者: from shop.views.product.ProductDetailView import get_template_names [as 別名]
class ProductDetailViewTestCase(TestCase):
def create_fixtures(self):
self.product = Product()
self.product.name = 'test'
self.product.short_description = 'test'
self.product.long_description = 'test'
self.product.unit_price = Decimal('1.0')
self.product.save()
self.view = ProductDetailView(kwargs={'pk':self.product.id})
def test_01_get_product_returns_correctly(self):
self.create_fixtures()
setattr(self.view, 'object', None)
obj = self.view.get_object()
inst = isinstance(obj,Product)
self.assertEqual(inst, True)
def test_02_get_templates_return_expected_values(self):
self.create_fixtures()
self.view = ProductDetailView()
setattr(self.view, 'object', None)
tmp = self.view.get_template_names()
self.assertEqual(len(tmp), 1)
示例2: ProductDetailViewTestCase
# 需要導入模塊: from shop.views.product import ProductDetailView [as 別名]
# 或者: from shop.views.product.ProductDetailView import get_template_names [as 別名]
class ProductDetailViewTestCase(TestCase):
def setUp(self):
self.product = Product()
self.product.name = "test"
self.product.short_description = "test"
self.product.long_description = "test"
self.product.unit_price = Decimal("1.0")
self.product.active = True
self.product.save()
self.view = ProductDetailView(kwargs={"pk": self.product.pk})
def test_get_product_returns_correctly(self):
setattr(self.view, "object", None)
obj = self.view.get_object()
inst = isinstance(obj, Product)
self.assertEqual(inst, True)
def test_get_templates_return_expected_values(self):
self.view = ProductDetailView()
setattr(self.view, "object", None)
tmp = self.view.get_template_names()
self.assertEqual(len(tmp), 1)