def test_box_cache_key_is_prefixed_by_objects_key(self): box = Box(self.publishable, 'box_type', []) # initialize the box's .params attribute box.prepare({}) tools.assert_true(box.get_cache_key().startswith( _get_key(KEY_PREFIX, self.publishable.content_type, pk=self.publishable.pk)))
def test_box_works_for_any_class(self): class TestClass(object): title = 'Heyoo' test_obj = TestClass() test_box = Box(test_obj, 'box_type', []) tools.assert_equals([ 'box/content_type/testclass/box_type.html', 'box/content_type/testclass/box.html', 'box/box_type.html', 'box/box.html' ], test_box._get_template_list()) template_loader.templates['box/content_type/testclass/box_type.html'] = '{{ object.title}}' tools.assert_equals('Heyoo', test_box.render(Context({})))
def test_box_works_for_any_class(self): class TestClass(object): title = 'Heyoo' test_obj = TestClass() test_box = Box(test_obj, 'box_type', []) tools.assert_equals([ 'box/content_type/testclass/box_type.html', 'box/content_type/testclass/box.html', 'box/box_type.html', 'box/box.html' ], test_box._get_template_list()) template_loader.templates[ 'box/content_type/testclass/box_type.html'] = '{{ object.title}}' tools.assert_equals('Heyoo', test_box.render(Context({})))
def test_box_works_for_any_class(self): class TestClass(object): title = "Heyoo" test_obj = TestClass() test_box = Box(test_obj, "box_type", []) tools.assert_equals( [ "box/content_type/testclass/box_type.html", "box/content_type/testclass/box.html", "box/box_type.html", "box/box.html", ], test_box._get_template_list(), ) template_loader.templates["box/content_type/testclass/box_type.html"] = "{{ object.title}}" tools.assert_equals("Heyoo", test_box.render(Context({})))
def test_box_template_path_contains_correct_content_type(self): publishable = Publishable.objects.get(pk=self.publishable.pk) article = publishable.target box_publishable = publishable.box_class(publishable, "box_type", []) box_article = Box(article, "box_type", []) template_list = [ "box/category/nested-category/content_type/articles.article/first-article/box_type.html", "box/category/nested-category/content_type/articles.article/box_type.html", "box/category/nested-category/content_type/articles.article/box.html", "box/content_type/articles.article/first-article/box_type.html", "box/content_type/articles.article/box_type.html", "box/content_type/articles.article/box.html", "box/box_type.html", "box/box.html", ] tools.assert_equals(template_list, box_publishable._get_template_list()) tools.assert_equals(template_list, box_article._get_template_list())
def test_box_template_path_contains_correct_content_type(self): publishable = Publishable.objects.get(pk=self.publishable.pk) article = publishable.target box_publishable = publishable.box_class(publishable, 'box_type', []) box_article = Box(article, 'box_type', []) template_list = [ 'box/category/nested-category/content_type/articles.article/first-article/box_type.html', 'box/category/nested-category/content_type/articles.article/box_type.html', 'box/category/nested-category/content_type/articles.article/box.html', 'box/content_type/articles.article/first-article/box_type.html', 'box/content_type/articles.article/box_type.html', 'box/content_type/articles.article/box.html', 'box/box_type.html', 'box/box.html', ] self.assert_equals(template_list, box_publishable._get_template_list()) self.assert_equals(template_list, box_article._get_template_list())
def test_box_cache_key_is_prefixed_by_objects_key(self): box = Box(self.publishable, 'box_type', []) # initialize the box's .params attribute box.prepare({}) tools.assert_true(box.get_cache_key().startswith(_get_key(KEY_PREFIX, self.publishable.content_type, pk=self.publishable.pk)))