Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ __pycache__/
/node_modules
/test-static
/test-media
/.idea
9 changes: 9 additions & 0 deletions laces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
from .components import Component


VERSION = (0, 1, 0)
__version__ = ".".join(map(str, VERSION))


__all__ = [
VERSION,
Component,
]
3 changes: 3 additions & 0 deletions laces/components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Component:
def render(self):
return "Hello, world!"
Empty file removed laces/migrations/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions laces/test/components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import laces


class StaticComponent(laces.Component):
pass
39 changes: 39 additions & 0 deletions laces/test/tests/test_components.py
Original file line number Diff line number Diff line change
@@ -0,0 +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.StaticComponent, laces.Component))

def test_defined_template(self):
self.assertEqual(
test_components.StaticComponent.template,
"test_components/static.html",
)

def test_render(self):
component = test_components.StaticComponent()

self.assertEqual(component.render(), "Hello, world!")
Loading