From 6db16fdfcbdd0c8fbdf57f7b3fcd83ea9a301d73 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Fri, 22 Dec 2017 10:45:30 +0000 Subject: [PATCH] Update the tests to work with the page model --- opentech/apply/models.py | 2 +- opentech/apply/tests/factories.py | 7 +++++++ opentech/apply/tests/test_models.py | 5 +++-- opentech/settings/dev.py | 2 +- requirements.txt | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/opentech/apply/models.py b/opentech/apply/models.py index f7833f419..29728c269 100644 --- a/opentech/apply/models.py +++ b/opentech/apply/models.py @@ -2,7 +2,6 @@ from django.db import models from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailcore.models import Page from wagtail.wagtailsearch import index -from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel from opentech.utils.models import SocialFields, ListingFields @@ -14,6 +13,7 @@ WORKFLOW_CLASS = { DoubleStage.name: DoubleStage, } + class ApplyHomePage(Page, SocialFields, ListingFields): # Only allow creating HomePages at the root level parent_page_types = ['wagtailcore.Page'] diff --git a/opentech/apply/tests/factories.py b/opentech/apply/tests/factories.py index a4f2cbd40..ab8339646 100644 --- a/opentech/apply/tests/factories.py +++ b/opentech/apply/tests/factories.py @@ -1,6 +1,8 @@ from django.forms import Form import factory +import wagtail_factories +from opentech.apply.models import FundPage from opentech.apply.workflow import Action, Phase, Stage, Workflow @@ -107,3 +109,8 @@ class WorkflowFactory(factory.Factory): stages = kwargs.pop('stage_classes') new_class = type(model_class.__name__, (model_class,), {'name': name, 'stage_classes': stages}) return new_class(*args, **kwargs) + + +class FundPageFactory(wagtail_factories.PageFactory): + class Meta: + model = FundPage diff --git a/opentech/apply/tests/test_models.py b/opentech/apply/tests/test_models.py index 60b2ca233..355f9a5a9 100644 --- a/opentech/apply/tests/test_models.py +++ b/opentech/apply/tests/test_models.py @@ -1,11 +1,12 @@ from django.test import TestCase -from opentech.apply.models import Fund from opentech.apply.workflow import SingleStage +from .factories import FundPageFactory + class TestFundModel(TestCase): 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_class, SingleStage) diff --git a/opentech/settings/dev.py b/opentech/settings/dev.py index 8992be6f8..c0dbe1a8f 100644 --- a/opentech/settings/dev.py +++ b/opentech/settings/dev.py @@ -8,7 +8,7 @@ SECRET_KEY = 'CHANGEME!!!' 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' diff --git a/requirements.txt b/requirements.txt index c05b0f826..b4faca247 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ wagtail-django-recaptcha==0.1 uwsgidecorators==1.1.0 mypy==0.550 factory_boy==2.9.2 +wagtail_factories==0.3.0 flake8 # Production dependencies -- GitLab