mirror of
https://github.com/django-components/django-components.git
synced 2025-07-24 16:53:47 +00:00
Add a basic Component class.
This commit is contained in:
parent
df22a4049f
commit
31261ece08
2 changed files with 26 additions and 0 deletions
|
@ -1,4 +1,16 @@
|
||||||
from .component_registry import ComponentRegistry, AlreadyRegistered, NotRegistered # NOQA
|
from .component_registry import ComponentRegistry, AlreadyRegistered, NotRegistered # NOQA
|
||||||
|
|
||||||
|
class Component(object):
|
||||||
|
def __init__(self):
|
||||||
|
self._media = self.Media()
|
||||||
|
|
||||||
|
def context(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
template = None
|
||||||
|
css = {}
|
||||||
|
js = ()
|
||||||
|
|
||||||
# This variable represents the global component registry
|
# This variable represents the global component registry
|
||||||
registry = ComponentRegistry()
|
registry = ComponentRegistry()
|
||||||
|
|
14
tests/test_component.py
Normal file
14
tests/test_component.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import unittest
|
||||||
|
from django_components import component
|
||||||
|
|
||||||
|
class ComponentRegistryTest(unittest.TestCase):
|
||||||
|
def test_simple_component(self):
|
||||||
|
class MyComponent(component.Component):
|
||||||
|
pass
|
||||||
|
|
||||||
|
comp = MyComponent()
|
||||||
|
|
||||||
|
self.assertEqual(comp.context(), {})
|
||||||
|
self.assertEqual(comp._media.template, None)
|
||||||
|
self.assertEqual(comp._media.css, {})
|
||||||
|
self.assertEqual(comp._media.js, ())
|
Loading…
Add table
Add a link
Reference in a new issue