From 5bc417867646292323e80b64d1b02864f80a4c9e Mon Sep 17 00:00:00 2001 From: Tibor Leupold Date: Sun, 29 Oct 2023 16:50:03 -0700 Subject: [PATCH 1/5] Ignore pycharm files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3acaffd..bbc77dd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ __pycache__/ /node_modules /test-static /test-media +/.idea From 16c998a6415496b3da6728801127c452e8a71851 Mon Sep 17 00:00:00 2001 From: Tibor Leupold Date: Sun, 29 Oct 2023 17:05:00 -0700 Subject: [PATCH 2/5] Add first test --- laces/test/components.py | 3 +++ laces/test/tests/test_components.py | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 laces/test/components.py create mode 100644 laces/test/tests/test_components.py diff --git a/laces/test/components.py b/laces/test/components.py new file mode 100644 index 0000000..115c0b0 --- /dev/null +++ b/laces/test/components.py @@ -0,0 +1,3 @@ +class TestComponent: + def render(self): + return "Hello, world!" diff --git a/laces/test/tests/test_components.py b/laces/test/tests/test_components.py new file mode 100644 index 0000000..8285525 --- /dev/null +++ b/laces/test/tests/test_components.py @@ -0,0 +1,10 @@ +from django import test + +from laces.test import components as test_components + + +class TestComponents(test.TestCase): + def test_component(self): + component = test_components.TestComponent() + + self.assertEqual(component.render(), "Hello, world!") From e1952422db81907bd9557b2262d24c757ce91cec Mon Sep 17 00:00:00 2001 From: Tibor Leupold Date: Sun, 29 Oct 2023 17:08:35 -0700 Subject: [PATCH 3/5] Remove migrations folder We probably won't need a migrations directory --- laces/migrations/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 laces/migrations/__init__.py diff --git a/laces/migrations/__init__.py b/laces/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 From 9ce5798e7eb4eac8444700232ade032882e75386 Mon Sep 17 00:00:00 2001 From: Tibor Leupold Date: Sun, 29 Oct 2023 17:14:10 -0700 Subject: [PATCH 4/5] Ensure test component uses inherits from package class --- laces/__init__.py | 9 +++++++++ laces/components.py | 2 ++ laces/test/components.py | 5 ++++- laces/test/tests/test_components.py | 7 ++++++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 laces/components.py diff --git a/laces/__init__.py b/laces/__init__.py index 9306fb8..e464367 100644 --- a/laces/__init__.py +++ b/laces/__init__.py @@ -1,2 +1,11 @@ +from .components import Component + + VERSION = (0, 1, 0) __version__ = ".".join(map(str, VERSION)) + + +__all__ = [ + VERSION, + Component, +] diff --git a/laces/components.py b/laces/components.py new file mode 100644 index 0000000..964f527 --- /dev/null +++ b/laces/components.py @@ -0,0 +1,2 @@ +class Component: + pass diff --git a/laces/test/components.py b/laces/test/components.py index 115c0b0..07c3dbe 100644 --- a/laces/test/components.py +++ b/laces/test/components.py @@ -1,3 +1,6 @@ -class TestComponent: +import laces + + +class TestComponent(laces.Component): def render(self): return "Hello, world!" diff --git a/laces/test/tests/test_components.py b/laces/test/tests/test_components.py index 8285525..d8712cb 100644 --- a/laces/test/tests/test_components.py +++ b/laces/test/tests/test_components.py @@ -1,9 +1,14 @@ from django import test +import laces + from laces.test import components as test_components -class TestComponents(test.TestCase): +class TestComponent(test.TestCase): + def test_inherits_laces_component(self): + self.assertTrue(issubclass(test_components.TestComponent, laces.Component)) + def test_component(self): component = test_components.TestComponent() From 43392c6d23eef88ab39b1897b7afa5a174ec96e1 Mon Sep 17 00:00:00 2001 From: Tibor Leupold Date: Sun, 29 Oct 2023 17:26:27 -0700 Subject: [PATCH 5/5] Add low-level test for the base class --- laces/components.py | 3 ++- laces/test/components.py | 5 ++--- laces/test/tests/test_components.py | 30 ++++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/laces/components.py b/laces/components.py index 964f527..400d046 100644 --- a/laces/components.py +++ b/laces/components.py @@ -1,2 +1,3 @@ class Component: - pass + def render(self): + return "Hello, world!" diff --git a/laces/test/components.py b/laces/test/components.py index 07c3dbe..4a2e7bc 100644 --- a/laces/test/components.py +++ b/laces/test/components.py @@ -1,6 +1,5 @@ import laces -class TestComponent(laces.Component): - def render(self): - return "Hello, world!" +class StaticComponent(laces.Component): + pass diff --git a/laces/test/tests/test_components.py b/laces/test/tests/test_components.py index d8712cb..e86be2e 100644 --- a/laces/test/tests/test_components.py +++ b/laces/test/tests/test_components.py @@ -1,15 +1,39 @@ +import typing + from django import test import laces +from laces import components from laces.test import components as test_components class TestComponent(test.TestCase): + def test_available(self): + self.assertTrue(hasattr(components, "Component")) + + def test_available_on_package_level(self): + self.assertEqual( + components.Component, + laces.Component, + ) + + def test_has_render_method(self): + self.assertTrue(hasattr(components.Component, "render")) + self.assertTrue(isinstance(components.Component.render, typing.Callable)) + + +class TestStaticComponent(test.TestCase): def test_inherits_laces_component(self): - self.assertTrue(issubclass(test_components.TestComponent, laces.Component)) + self.assertTrue(issubclass(test_components.StaticComponent, laces.Component)) + + def test_defined_template(self): + self.assertEqual( + test_components.StaticComponent.template, + "test_components/static.html", + ) - def test_component(self): - component = test_components.TestComponent() + def test_render(self): + component = test_components.StaticComponent() self.assertEqual(component.render(), "Hello, world!")