Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_07_default_render_method(self):
class SomethingElse(models.Model):
class Meta:
abstract = True
def render_region(self):
return 'hello'
type = ExampleCMSBase.create_content_type(SomethingElse)
obj = type()
self.assertRaises(NotImplementedError, lambda: obj.render())
obj.region = 'region'
self.assertEqual(obj.render(), 'hello')
lambda: ExampleCMSBase.create_content_type(TestContentType))
lambda: ExampleCMSBase.create_content_type(TestContentType))
lambda: ExampleCMSBase.create_content_type(RawContent))
def test_01_simple_content_type_creation(self):
self.assertEqual(ExampleCMSBase.content_type_for(FileContent), None)
ExampleCMSBase.create_content_type(ContactFormContent)
ExampleCMSBase.create_content_type(FileContent, regions=('region2',))
# no POSITION_CHOICES, should raise
self.assertRaises(ImproperlyConfigured,
lambda: ExampleCMSBase.create_content_type(ImageContent))
ExampleCMSBase.create_content_type(RawContent)
ExampleCMSBase.create_content_type(RichTextContent)
# test creating a cotent with arguments, but no initialize_type classmethod
ExampleCMSBase.create_content_type(VideoContent, arbitrary_arg='arbitrary_value')
# content_type_for should return None if it does not have a subclass registered
self.assertEqual(ExampleCMSBase.content_type_for(Empty), None)
assert 'filecontent' not in dict(ExampleCMSBase.template.regions[0].content_types).values()
assert 'filecontent' in dict(ExampleCMSBase.template.regions[1].content_types).values()
def test_02_rsscontent_creation(self):
# this test resides in its own method because the required feedparser
# module is not available everywhere
from feincms.content.rss.models import RSSContent
ExampleCMSBase.create_content_type(RSSContent)
def test_01_simple_content_type_creation(self):
self.assertEqual(ExampleCMSBase.content_type_for(FileContent), None)
ExampleCMSBase.create_content_type(ContactFormContent)
ExampleCMSBase.create_content_type(FileContent, regions=('region2',))
# no POSITION_CHOICES, should raise
self.assertRaises(ImproperlyConfigured,
lambda: ExampleCMSBase.create_content_type(ImageContent))
ExampleCMSBase.create_content_type(RawContent)
ExampleCMSBase.create_content_type(RichTextContent)
# test creating a cotent with arguments, but no initialize_type classmethod
ExampleCMSBase.create_content_type(VideoContent, arbitrary_arg='arbitrary_value')
# content_type_for should return None if it does not have a subclass registered
self.assertEqual(ExampleCMSBase.content_type_for(Empty), None)
assert 'filecontent' not in dict(ExampleCMSBase.template.regions[0].content_types).values()
assert 'filecontent' in dict(ExampleCMSBase.template.regions[1].content_types).values()
def test_01_simple_content_type_creation(self):
self.assertEqual(ExampleCMSBase.content_type_for(FileContent), None)
ExampleCMSBase.create_content_type(ContactFormContent)
ExampleCMSBase.create_content_type(FileContent, regions=('region2',))
# no POSITION_CHOICES, should raise
self.assertRaises(ImproperlyConfigured,
lambda: ExampleCMSBase.create_content_type(ImageContent))
ExampleCMSBase.create_content_type(RawContent)
ExampleCMSBase.create_content_type(RichTextContent)
# test creating a cotent with arguments, but no initialize_type classmethod
ExampleCMSBase.create_content_type(VideoContent, arbitrary_arg='arbitrary_value')
# content_type_for should return None if it does not have a subclass registered
self.assertEqual(ExampleCMSBase.content_type_for(Empty), None)
assert 'filecontent' not in dict(ExampleCMSBase.template.regions[0].content_types).values()
def test_07_default_render_method(self):
class SomethingElse(models.Model):
class Meta:
abstract = True
def render_region(self):
return 'hello'
type = ExampleCMSBase.create_content_type(SomethingElse)
obj = type()
self.assertRaises(NotImplementedError, lambda: obj.render())
obj.region = 'region'
self.assertEqual(obj.render(), 'hello')
def test_01_simple_content_type_creation(self):
self.assertEqual(ExampleCMSBase.content_type_for(FileContent), None)
ExampleCMSBase.create_content_type(ContactFormContent)
ExampleCMSBase.create_content_type(FileContent, regions=('region2',))
# no POSITION_CHOICES, should raise
self.assertRaises(ImproperlyConfigured,
lambda: ExampleCMSBase.create_content_type(ImageContent))
ExampleCMSBase.create_content_type(RawContent)
ExampleCMSBase.create_content_type(RichTextContent)
# test creating a cotent with arguments, but no initialize_type classmethod
ExampleCMSBase.create_content_type(VideoContent, arbitrary_arg='arbitrary_value')
# content_type_for should return None if it does not have a subclass registered
self.assertEqual(ExampleCMSBase.content_type_for(Empty), None)
assert 'filecontent' not in dict(ExampleCMSBase.template.regions[0].content_types).values()
assert 'filecontent' in dict(ExampleCMSBase.template.regions[1].content_types).values()