def test_create_attach_get(self, client):
     """ get the form for attaching content """
     root = Node.root()
     Type1(node=root).save()
     request = superuser_request("/", type=Type1.get_name())
     handler = MainHandlerTestable(request=request, instance=root)
     create = handler.create(type=Type1.get_name(), attach=True)
     assert create['path'] == "wheelcms_axle/create.html"
     assert 'form' in create['context']
Beispiel #2
0
    def test_create_translation_post(self, client, root):
        """
            Creating a translation on existing content is actually
            an update operation (it's handled by the update() method.
            Test the POST of the form, the actual creation of the
            translation
        """
        Type1(node=root, language="en").save()
        request = superuser_request("/edit", method="POST",
                                    type=Type1.get_name(),
                                    title="Translation NL",
                                    language="nl")
        translation.activate('nl')

        view = MainHandlerTestable()
        update = view.dispatch(request, nodepath="", handlerpath="edit")

        assert update.status_code == 302  # redirect

        translated = root.content(language="nl")
        assert translated is not None
        assert translated.title == "Translation NL"
        assert translated.owner == request.user

        # verify we've redirected back to the created content
        assert update['location'] == translated.get_absolute_url()
Beispiel #3
0
 def test_update_root(self, client, root):
     """ test /edit """
     Type1(node=root).save()
     request = superuser_request("/edit", method="POST", type=Type1.get_name())
     view = MainHandlerTestable()
     res = view.dispatch(request, nodepath="", handlerpath="edit")
     assert res['path'] == "wheelcms_axle/update.html"
     assert 'form' in res['context']
 def test_create_get_root(self, client):
     """ test create on root - get """
     root = Node.root()
     Type1(node=root).save()
     request = superuser_request("/", type=Type1.get_name())
     handler = MainHandlerTestable(request=request, instance=root)
     create = handler.create()
     assert create['path'] == "wheelcms_axle/create.html"
     assert 'form' in create['context']
Beispiel #5
0
    def test_create_attach_get(self, client, root):
        """ get the form for attaching content """
        Type1(node=root).save()
        request = superuser_request("/", type=Type1.get_name(), attach=True)
        view = MainHandlerTestable()
        res = view.dispatch(request, nodepath="", handlerpath="create")

        assert res['path'] == "wheelcms_axle/create.html"
        assert 'form' in res['context']
 def test_update_root(self, client):
     """ test /edit """
     root = Node.root()
     Type1(node=root).save()
     request = superuser_request("/edit", method="POST", type=Type1.get_name())
     instance = MainHandlerTestable.coerce(dict(instance=""))
     handler = MainHandlerTestable(request=request, instance=instance)
     update = handler.update()
     assert update['path'] == "wheelcms_axle/update.html"
     assert 'form' in update['context']
Beispiel #7
0
    def test_create_attach_post(self, client, root):
        """ post the form for attaching content """
        request = superuser_request("/create", method="POST",
                                      title="Test", language="en",
                                      type=Type1.get_name(), attach=True)
        view = MainHandlerTestable()

        res = view.dispatch(request, nodepath="", handlerpath="create")
        assert res.status_code == 302

        assert root.content().title == "Test"
    def test_attached_form(self, client):
        """ The form when attaching should not contain a slug field since it
            will be attached to an existing node """
        root = Node.root()
        Type1(node=root).save()
        request = superuser_request("/")
        handler = MainHandlerTestable(request=request, instance=root)
        create = handler.create(type=Type1.get_name(), attach=True)

        form = create['context']['form']
        assert 'slug' not in form.fields
Beispiel #9
0
    def test_attached_form(self, client, root):
        """ The form when attaching should not contain a slug field since it
            will be attached to an existing node """
        Type1(node=root).save()
        request = superuser_request("/", type=Type1.get_name(), attach=True)
        handler = MainHandlerTestable()

        res = handler.dispatch(request, nodepath="", handlerpath="create")

        form = res['context']['form']
        assert 'slug' not in form.fields
    def test_create_post(self, client):
        request = superuser_request("/create", method="POST",
                                      title="Test",
                                      slug="test",
                                      language="en")
        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(instance=root))
        pytest.raises(Redirect, handler.create, type=Type1.get_name())

        node = Node.get("/test")
        assert node.content().title == "Test"
    def test_create_attach_post(self, client):
        """ post the form for attaching content """
        request = superuser_request("/create", method="POST",
                                      title="Test", language="en")
        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(instance=root))
        pytest.raises(Redirect, handler.create, type=Type1.get_name(), attach=True)

        root = Node.root()
        # pytest.set_trace()
        assert root.content().title == "Test"
Beispiel #12
0
    def test_create_post_unicode(self, client, root):
        """ issue #693 - unicode enoding issue """
        request = superuser_request("/create", method="POST",
                           title=u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!",
                           slug="test",
                           language="en",
                           type=Type1.get_name())
        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="", handlerpath="create")

        assert res.status_code == 302
        node = Node.get("/test")
        assert node.content().title == u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!"
    def test_create_post_unicode(self, client):
        """ issue #693 - unicode enoding issue """
        request = superuser_request("/create", method="POST",
                           title=u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!",
                           slug="test",
                           language="en")
        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(instance=root))
        pytest.raises(Redirect, handler.create, type=Type1.get_name())

        node = Node.get("/test")
        assert node.content().title == u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!"
    def test_create_get(self, client):
        """ create should override and add Create operation crumb """
        root = Node.root()
        Type1(node=root, title="Root").save()
        child = root.add("child")
        Type1(node=child, title="Child").save()
        request = superuser_request("/child/create")

        handler = MainHandlerTestable(request=request, instance=child)
        context = handler.create(type=Type1.get_name())['context']
        assert 'breadcrumb' in context
        assert context['breadcrumb'] == [('Home', root.get_absolute_url()),
                                         ('Child', child.get_absolute_url()),
                                         ('Create "%s"' % Type1Type.title, '')]
    def test_create_translation(self, client):
        root = Node.root()
        Type1(node=root, language="en").save()
        request = superuser_request("/edit", method="POST", type=Type1.get_name())
        request.session = {'admin_language':'nl'}

        instance = MainHandlerTestable.coerce(dict(instance=""))
        handler = MainHandlerTestable(request=request, instance=instance)
        update = handler.update()
        assert update['path'] == "wheelcms_axle/update.html"
        assert 'form' in update['context']
        f = update['context']['form']

        assert f.initial['language'] == 'nl'
Beispiel #16
0
    def test_create_post(self, client, root):
        request = superuser_request("/create", method="POST",
                                      title="Test",
                                      slug="test",
                                      language="en",
                                      type=Type1.get_name())
        handler = MainHandlerTestable()

        res = handler.dispatch(request, nodepath="", handlerpath="create")
        assert res.status_code == 302


        node = Node.get("/test")
        assert node.content().title == "Test"
    def setup_handler(self, user=None, method="GET", with_instance=False,
                      state="private"):
        """ setup the mainhandler """
        root = Node.root()
        if with_instance:
            cont = Type1Type.create(node=root, state=state).save()
            cont.assign_perms()
        request = create_request(method, "/", data={'type':Type1.get_name()})
        if self.provide_user():
            request.user = self.provide_user()
        handler = MainHandler()
        handler.init_from_request(request)
        handler.instance = root

        return handler
    def test_handler_create(self, superuser, client):
        """ The handler *can* set the user """
        request = create_request("POST", "/create",
                                 data=dict(title="Test",
                                           slug="test",
                                           language="en",
                                           type=Type1.get_name()))
        request.user = superuser

        handler = MainHandler()
        res = handler.dispatch(request, nodepath="", handlerpath="create")
        assert res.status_code == 302

        node = Node.get("/test")
        assert node.content().title == "Test"
        assert node.content().owner == superuser
Beispiel #19
0
    def test_create_get(self, client, root):
        """ create should override and add Create operation crumb """
        Type1(node=root, title="Root").save()
        child = root.add("child")
        Type1(node=child, title="Child").save()
        request = superuser_request("/child/create", type=Type1.get_name())

        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath=child.path, handlerpath="create")

        context = res['context']

        assert 'breadcrumb' in context
        assert context['breadcrumb'] == [('Home', root.get_absolute_url()),
                                         ('Child', child.get_absolute_url()),
                                         ('Create "%s"' % Type1Type.title, '')]
    def test_handler_create(self, client):
        """ The handler *can* set the user """
        request = create_request("POST", "/create",
                                 data=dict(title="Test",
                                           slug="test",
                                           language="en"))
        request.user = self.user

        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(parent=root))
        pytest.raises(Redirect, handler.create, type=Type1.get_name())

        node = Node.get("/test")
        assert node.content().title == "Test"
        assert node.content().owner == self.user
Beispiel #21
0
    def test_create_translation_get(self, client, root):
        """
            Creating a translation on existing content is actually
            an update operation (it's handled by the update() method.
            Test the GET of the translation form
        """
        Type1(node=root, language="en").save()
        request = superuser_request("/", method="GET",
                                    type=Type1.get_name())
        translation.activate('nl')

        view = MainHandlerTestable()
        update = view.dispatch(request, nodepath="", handlerpath="edit")


        assert update['path'] == "wheelcms_axle/update.html"
        assert 'form' in update['context']
        f = update['context']['form']

        assert f.initial['language'] == 'nl'
 def test_create_post(self, client):
     """ only powerusers can post the createform """
     handler = self.setup_handler(method="POST")
     self.check(handler.create, type=Type1.get_name())
 def test_create_get(self, client):
     """ only powerusers can get the createform """
     handler = self.setup_handler()
     self.check(handler.create, type=Type1.get_name())