mirror of
https://github.com/django-components/django-components.git
synced 2025-10-17 17:27:13 +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 {}
|
||||
|
||||
def template(self, context):
|
||||
return ""
|
||||
raise NotImplementedError("Missing template() method on component")
|
||||
|
||||
def render_dependencies(self):
|
||||
return self.media.render()
|
||||
|
|
|
@ -6,7 +6,15 @@ from django_components import component
|
|||
|
||||
from .django_test_setup import * # NOQA
|
||||
|
||||
|
||||
class ComponentRegistryTest(SimpleTestCase):
|
||||
def test_empty_component(self):
|
||||
class EmptyComponent(component.Component):
|
||||
pass
|
||||
|
||||
with self.assertRaises(NotImplementedError):
|
||||
EmptyComponent().template({})
|
||||
|
||||
def test_simple_component(self):
|
||||
class SimpleComponent(component.Component):
|
||||
def context(self, variable=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue