Skip to content

Commit

Permalink
Test nested Media class def in Component subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrlpld committed Dec 11, 2023
1 parent 5cc1c5c commit d1c14fa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions laces/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ def get_context_data(self, parent_context):
with self.assertRaises(TypeError):
ExampleComponent().render_html()

def test_media_defined_through_nested_class(self):
"""
Test the `media` property when defined through a nested class.
The `media` property is added through the `metaclass=MediaDefiningClass`
definition. This test ensures that the `media` property is available when
configured through a nested class.
"""

# -----------------------------------------------------------------------------
class ExampleComponent(Component):
class Media:
css = {"all": ["example.css"]}
js = ["example.js"]

# -----------------------------------------------------------------------------

result = ExampleComponent().media

self.assertIsInstance(result, Media)
self.assertEqual(result._css, {"all": ["example.css"]})
self.assertEqual(result._js, ["example.js"])

def tearDown(self):
os.remove(path=self.example_template)

Expand Down

0 comments on commit d1c14fa

Please sign in to comment.