start using correct model in tests
This commit is contained in:
committed by
Michael van Tellingen
parent
f693e62bbf
commit
623af1a06a
25
tests/factories/site.py
Normal file
25
tests/factories/site.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import factory
|
||||||
|
from django.utils.text import slugify
|
||||||
|
from wagtail.wagtailcore.models import Site
|
||||||
|
from wagtail_factories.factories import MP_NodeFactory
|
||||||
|
|
||||||
|
from tests.sandbox.pages.models import HomePage
|
||||||
|
|
||||||
|
|
||||||
|
class PageFactory(MP_NodeFactory):
|
||||||
|
title = 'Test page'
|
||||||
|
slug = factory.LazyAttribute(lambda obj: slugify(obj.title))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = HomePage
|
||||||
|
|
||||||
|
|
||||||
|
class SiteFactory(factory.DjangoModelFactory):
|
||||||
|
hostname = 'localhost'
|
||||||
|
port = factory.Sequence(lambda n: 81 + n)
|
||||||
|
site_name = 'Test site'
|
||||||
|
root_page = factory.SubFactory(PageFactory, parent=None)
|
||||||
|
is_default_site = False
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Site
|
@ -1,10 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.11.1 on 2017-05-31 06:50
|
# Generated by Django 1.11.1 on 2017-05-31 06:40
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import wagtail.wagtailcore.fields
|
import wagtail.wagtailcore.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -12,20 +12,23 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('wagtail_personalisation', '0008_devicerule'),
|
('wagtail_personalisation', '0009_auto_20170531_0428'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='HomePage',
|
name='HomePage',
|
||||||
fields=[
|
fields=[
|
||||||
('personalisablepage_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtail_personalisation.PersonalisablePage')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
('subtitle', models.CharField(max_length=255)),
|
('is_segmented', models.BooleanField(default=False)),
|
||||||
|
('subtitle', models.CharField(blank=True, default='', max_length=255)),
|
||||||
('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')),
|
('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')),
|
||||||
|
('canonical_page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='variations', to='pages.HomePage')),
|
||||||
|
('segment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='segments', to='wagtail_personalisation.Segment')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
},
|
},
|
||||||
bases=('wagtail_personalisation.personalisablepage',),
|
bases=('wagtailcore.page', models.Model),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -63,7 +63,7 @@ MIDDLEWARE = (
|
|||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
'wagtail_personalisation',
|
'wagtail_personalisation',
|
||||||
'tests',
|
'tests.sandbox.pages',
|
||||||
|
|
||||||
'wagtail.contrib.modeladmin',
|
'wagtail.contrib.modeladmin',
|
||||||
'wagtail.wagtailsearch',
|
'wagtail.wagtailsearch',
|
||||||
|
@ -6,7 +6,7 @@ import pytest
|
|||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
from wagtail.wagtailcore.models import Site
|
from wagtail.wagtailcore.models import Site
|
||||||
from wagtail_factories import SiteFactory
|
from tests.factories.site import SiteFactory
|
||||||
|
|
||||||
from wagtail_personalisation import rules
|
from wagtail_personalisation import rules
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user