mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 06:18:17 +00:00
refactor: cleanup docs, add docs on Render API, allow get_context_data return None (#1110)
* refactor: cleanup docs, add docs on Render API, allow get_context_data return None * refactor: fix linter and tests
This commit is contained in:
parent
9ede779fa3
commit
613dfea379
15 changed files with 604 additions and 226 deletions
|
@ -362,6 +362,18 @@ class TestComponent:
|
|||
|
||||
assert get_component_by_class_id(SimpleComponent.class_id) == SimpleComponent
|
||||
|
||||
def test_get_component_by_id_raises_on_missing_component(self):
|
||||
with pytest.raises(KeyError):
|
||||
get_component_by_class_id("nonexistent")
|
||||
|
||||
def test_get_context_data_returns_none(self):
|
||||
class SimpleComponent(Component):
|
||||
template = "Hello"
|
||||
|
||||
def get_context_data(self):
|
||||
return None
|
||||
|
||||
assert SimpleComponent.render() == "Hello"
|
||||
|
||||
@djc_test
|
||||
class TestComponentRender:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue