Add test for component with undefined template method.

This commit is contained in:
Emil Stenström 2020-06-07 17:07:24 +02:00
parent ff2a674200
commit 5f63a6a6bd
2 changed files with 9 additions and 1 deletions

View file

@ -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()

View file

@ -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):