mirror of
https://github.com/django-components/django-components.git
synced 2025-12-09 22:11:06 +00:00
Add test for component with undefined template method.
This commit is contained in:
parent
ff2a674200
commit
5f63a6a6bd
2 changed files with 9 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ class Component(with_metaclass(MediaDefiningClass)):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def template(self, context):
|
def template(self, context):
|
||||||
return ""
|
raise NotImplementedError("Missing template() method on component")
|
||||||
|
|
||||||
def render_dependencies(self):
|
def render_dependencies(self):
|
||||||
return self.media.render()
|
return self.media.render()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,15 @@ from django_components import component
|
||||||
|
|
||||||
from .django_test_setup import * # NOQA
|
from .django_test_setup import * # NOQA
|
||||||
|
|
||||||
|
|
||||||
class ComponentRegistryTest(SimpleTestCase):
|
class ComponentRegistryTest(SimpleTestCase):
|
||||||
|
def test_empty_component(self):
|
||||||
|
class EmptyComponent(component.Component):
|
||||||
|
pass
|
||||||
|
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
EmptyComponent().template({})
|
||||||
|
|
||||||
def test_simple_component(self):
|
def test_simple_component(self):
|
||||||
class SimpleComponent(component.Component):
|
class SimpleComponent(component.Component):
|
||||||
def context(self, variable=None):
|
def context(self, variable=None):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue