Skip to content
Snippets Groups Projects
Commit 6db16fdf authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Update the tests to work with the page model

parent 272f63be
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ from django.db import models ...@@ -2,7 +2,6 @@ from django.db import models
from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.models import Page
from wagtail.wagtailsearch import index from wagtail.wagtailsearch import index
from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
from opentech.utils.models import SocialFields, ListingFields from opentech.utils.models import SocialFields, ListingFields
...@@ -14,6 +13,7 @@ WORKFLOW_CLASS = { ...@@ -14,6 +13,7 @@ WORKFLOW_CLASS = {
DoubleStage.name: DoubleStage, DoubleStage.name: DoubleStage,
} }
class ApplyHomePage(Page, SocialFields, ListingFields): class ApplyHomePage(Page, SocialFields, ListingFields):
# Only allow creating HomePages at the root level # Only allow creating HomePages at the root level
parent_page_types = ['wagtailcore.Page'] parent_page_types = ['wagtailcore.Page']
......
from django.forms import Form from django.forms import Form
import factory import factory
import wagtail_factories
from opentech.apply.models import FundPage
from opentech.apply.workflow import Action, Phase, Stage, Workflow from opentech.apply.workflow import Action, Phase, Stage, Workflow
...@@ -107,3 +109,8 @@ class WorkflowFactory(factory.Factory): ...@@ -107,3 +109,8 @@ class WorkflowFactory(factory.Factory):
stages = kwargs.pop('stage_classes') stages = kwargs.pop('stage_classes')
new_class = type(model_class.__name__, (model_class,), {'name': name, 'stage_classes': stages}) new_class = type(model_class.__name__, (model_class,), {'name': name, 'stage_classes': stages})
return new_class(*args, **kwargs) return new_class(*args, **kwargs)
class FundPageFactory(wagtail_factories.PageFactory):
class Meta:
model = FundPage
from django.test import TestCase from django.test import TestCase
from opentech.apply.models import Fund
from opentech.apply.workflow import SingleStage from opentech.apply.workflow import SingleStage
from .factories import FundPageFactory
class TestFundModel(TestCase): class TestFundModel(TestCase):
def test_can_access_workflow_class(self): def test_can_access_workflow_class(self):
fund = Fund.objects.create(name='Internet Freedom Fund') fund = FundPageFactory(parent=None)
self.assertEqual(fund.workflow, 'single') self.assertEqual(fund.workflow, 'single')
self.assertEqual(fund.workflow_class, SingleStage) self.assertEqual(fund.workflow_class, SingleStage)
...@@ -8,7 +8,7 @@ SECRET_KEY = 'CHANGEME!!!' ...@@ -8,7 +8,7 @@ SECRET_KEY = 'CHANGEME!!!'
INTERNAL_IPS = ('127.0.0.1', '10.0.2.2') INTERNAL_IPS = ('127.0.0.1', '10.0.2.2')
ALLOWED_HOSTS= ['apply.localhost', 'localhost', '127.0.0.1'] ALLOWED_HOSTS = ['apply.localhost', 'localhost', '127.0.0.1']
BASE_URL = 'http://localhost:8000' BASE_URL = 'http://localhost:8000'
......
...@@ -9,6 +9,7 @@ wagtail-django-recaptcha==0.1 ...@@ -9,6 +9,7 @@ wagtail-django-recaptcha==0.1
uwsgidecorators==1.1.0 uwsgidecorators==1.1.0
mypy==0.550 mypy==0.550
factory_boy==2.9.2 factory_boy==2.9.2
wagtail_factories==0.3.0
flake8 flake8
# Production dependencies # Production dependencies
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment