Exemplo n.º 1
0
    def test_create_translation_root_get(self, client, root):
        """ test case where root has content but current language
            is not translated """
        Type1(node=root, title="Hello", language="en").save()
        request = superuser_request("/edit", method="GET",
                                    language="nl")
        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="", handlerpath="edit")

        assert 'slug' not in res['context']['form'].fields
Exemplo n.º 2
0
    def test_update_post(self, client, root):
        Type1(node=root, title="Hello").save()
        request = superuser_request("/edit", method="POST",
                                      title="Test",
                                      slug="",
                                      language="en")
        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="", handlerpath="edit")
        assert res.status_code == 302

        assert root.content().title == "Test"
Exemplo n.º 3
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
Exemplo n.º 4
0
    def test_update_post_unicode(self, client, root):
        """ update content with unicode with new unicode title """
        Type1(node=root, title=u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!").save()
        request = superuser_request("/edit", method="POST",
                                      title="TTesting «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!",
                                      slug="",
                                      language="en")
        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="", handlerpath="edit")

        assert res.status_code == 302
        assert root.content().title == u"TTesting «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!"
Exemplo n.º 5
0
    def test_change_slug_inuse(self, client, root):
        Type1(node=root.add("inuse"), title="InUse").save()
        other = Type1(node=root.add("other"), title="Other").save()
        request = superuser_request("/other/update", method="POST",
                                    title="Other", slug="inuse",
                                    language="en")

        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="/other", handlerpath="edit")

        form = res['context']['form']
        assert not form.is_valid()
        assert 'slug' in form.errors
Exemplo n.º 6
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!"
Exemplo n.º 7
0
    def test_change_slug_available(self, client, root):
        Type1(node=root.add("inuse"), title="InUse").save()
        other = Type1(node=root.add("other"), title="Other").save()
        request = superuser_request("/other/update", method="POST",
                                    title="Other", slug="inuse2",
                                    language="en")

        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="/other", handlerpath="edit")

        assert res.status_code == 302

        form = handler.context['form']
        assert form.is_valid()
Exemplo n.º 8
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"
Exemplo n.º 9
0
    def test_create_image(self, client, root):
        request = superuser_request("/create", method="POST",
                                      title="Test",
                                      slug="test",
                                      language="en",
                                      storage=filedata,
                                      type=TestImage.get_name())
        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="", handlerpath="create")

        assert res.status_code == 302

        node = Node.get("/test")
        filedata.seek(0)
        assert node.content().storage.read() == filedata.read()
Exemplo n.º 10
0
    def test_update_image(self, client, root):
        node = root.add("test")
        TestImage(node=node, title="image", storage=filedata).save()
        request = superuser_request("/test/edit", method="POST",
                                      title="Test",
                                      slug="",
                                      language="en",
                                      storage=filedata2)
        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath="/test", handlerpath="edit")

        assert res.status_code == 302

        node = Node.get("/test")
        filedata2.seek(0)
        assert node.content().storage.read() == filedata2.read()
Exemplo n.º 11
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, '')]
Exemplo n.º 12
0
    def test_create_translation_root_post(self, client, root):
        """ test case where root has content but current language
            is not translated """
        Type1(node=root, title="Hello", language="en").save()
        request = superuser_request("/edit", method="POST",
                                    title="hello",
                                    language="nl")
        locale.activate_content_language('nl')

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

        assert res.status_code == 302
        assert root.content(language='nl')
        assert root.content(language='en')
        assert root.content(language='nl') != root.content(language='en')
Exemplo n.º 13
0
    def test_update(self, client, root):
        """ update should override and add Update operation crumb """
        Type1(node=root, title="Root").save()
        child = root.add("child")
        Type1(node=child, title="Child").save()
        request = superuser_request("/child/edit", method="GET")

        handler = MainHandlerTestable()
        res = handler.dispatch(request, nodepath=child.path, handlerpath="edit")
        context = res['context']

        assert 'breadcrumb' in context
        assert context['breadcrumb'] == [
                   ('Home', root.get_absolute_url()),
                   ('Child', child.get_absolute_url()),
                   ('Edit "%s" (%s)' % (child.content().title,
                                        Type1Type.title), '')]
Exemplo n.º 14
0
    def test_handle_list(self, client, root):
        """ issue #799 - no raw node is returned for getting slug or path """
        t = Type1(node=root.add("attached"), title="Attached").save()
        u = root.add("unattached")

        request = superuser_request("/list", method="GET")

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

        path = res['path']
        context = res['context']

        assert path == "wheelcms_axle/contents.html"
        assert 'children' in context
        children = context['children']
        assert len(children) == 2

        assert children[0]['active'] == t
        assert children[1]['active'] is None
        # fails because children[1]['node'] is language-wrapped
        # assert children[1]['node'] == u
        assert children[1]['node'].path == u.path