示例#1
0
    def test_creates_pages_for_category_nodes(self):
        nodes = [factories.PageNodeFactory(), factories.PageNodeFactory()]

        FancyPage = get_page_model()
        self.assertEqual(FancyPage.objects.count(), 0)

        call_command('fp_create_pages_for_nodes')

        self.assertEqual(FancyPage.objects.count(), 2)
        self.assertItemsEqual([p.node for p in FancyPage.objects.all()], nodes)
    def handle_noargs(self, **options):
        # this makes the management command work nicely with the South
        # frozen ORM
        if 'orm' in options:
            orm = options['orm']
            try:
                Category = orm[FP_NODE_MODEL]
            except KeyError:
                CommandError(
                    "could not find model 'Category'. Aborting command.")
            try:
                FancyPage = orm[FP_PAGE_MODEL]
            except KeyError:
                CommandError(
                    "could not find model 'FancyPage'. Aborting command.")
        else:
            Category = get_node_model()
            FancyPage = get_page_model()

        for category in Category.objects.filter(page=None):
            # there seems to be no FP for this category so let's create one.
            FancyPage.objects.create(node=category)
    def handle_noargs(self, **options):
        # this makes the management command work nicely with the South
        # frozen ORM
        if 'orm' in options:
            orm = options['orm']
            try:
                Category = orm[FP_NODE_MODEL]
            except KeyError:
                CommandError(
                    "could not find model 'Category'. Aborting command.")
            try:
                FancyPage = orm[FP_PAGE_MODEL]
            except KeyError:
                CommandError(
                    "could not find model 'FancyPage'. Aborting command.")
        else:
            Category = get_node_model()
            FancyPage = get_page_model()

        for category in Category.objects.filter(page=None):
            # there seems to be no FP for this category so let's create one.
            FancyPage.objects.create(node=category)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
import mock

from django.test import TestCase
from django.core import exceptions
from django.template import loader, Context, RequestContext
from django.template.base import Parser, Token, TOKEN_BLOCK

from fancypages import models
from fancypages.test import testcases, factories
from fancypages.templatetags.fp_container_tags import parse_arguments
from fancypages.utils import get_container_names_from_template, get_page_model

FancyPage = get_page_model()


class TestParsingObjectTokens(TestCase):

    def get_parser_and_token(self, contents):
        token = Token(TOKEN_BLOCK, contents)
        parser = Parser([token])
        return parser, token

    def test_extracts_mandatory_container_name(self):
        parser, token = self.get_parser_and_token(
            "fp_object_container another-container")
        self.assertItemsEqual(
            parse_arguments(parser, token),
            {'container_name': 'another-container'})
示例#5
0
from django.db.models import get_model
from django.utils import simplejson as json
from django.core.urlresolvers import reverse

from fancypages.test import factories
from fancypages.test import testcases
from fancypages.utils import get_node_model, get_page_model

PageType = get_model('fancypages', 'PageType')
PageNode = get_node_model()
FancyPage = get_page_model()
Container = get_model('fancypages', 'Container')
TextBlock = get_model('fancypages', 'TextBlock')
TabBlock = get_model('fancypages', 'TabBlock')
ContentBlock = get_model('fancypages', 'ContentBlock')


class TestTheBlockTypeApi(testcases.FancyPagesWebTest):
    is_staff = True

    def setUp(self):
        super(TestTheBlockTypeApi, self).setUp()
        self.container = Container.objects.create(name="test")

    def test_is_not_available_to_anonymous_users(self):
        self.app.get(reverse('fp-api:block-type-list'), status=403)

    def test_returns_a_block_type_form_for_container(self):
        page = self.get(
            reverse('fp-api:block-type-list'),
            params={'container': self.container.uuid})