policies: change .form() and .serializer() to properties, add tests
This commit is contained in:
31
passbook/flows/tests/test_models.py
Normal file
31
passbook/flows/tests/test_models.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""flow model tests"""
|
||||
from typing import Callable, Type
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.test import TestCase
|
||||
|
||||
from passbook.flows.models import Stage
|
||||
from passbook.flows.stage import StageView
|
||||
|
||||
|
||||
class TestStageProperties(TestCase):
|
||||
"""Generic model properties tests"""
|
||||
|
||||
|
||||
def stage_tester_factory(model: Type[Stage]) -> Callable:
|
||||
"""Test a form"""
|
||||
|
||||
def tester(self: TestStageProperties):
|
||||
model_inst = model()
|
||||
self.assertTrue(issubclass(model_inst.form, ModelForm))
|
||||
self.assertTrue(issubclass(model_inst.type, StageView))
|
||||
|
||||
return tester
|
||||
|
||||
|
||||
for stage_type in Stage.__subclasses__():
|
||||
setattr(
|
||||
TestStageProperties,
|
||||
f"test_stage_{stage_type.__name__}",
|
||||
stage_tester_factory(stage_type),
|
||||
)
|
||||
Reference in New Issue
Block a user