def test_create_translation_root_get(self, client):
        """ test case where root has content but current language
            is not translated """
        root = Node.root()
        Type1(node=root, title="Hello", language="en").save()
        request = superuser_request("/edit", method="GET",
                                    language="nl")
        handler = MainHandler(request=request, post=False, instance=root)
        handler.update()

        assert 'slug' not in handler.context['form'].fields
    def test_change_slug_inuse(self, client):
        root = Node.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(request=request, post=True, instance=other.node)
        handler.update()

        form = handler.context['form']
        assert not form.is_valid()
        assert 'slug' in form.errors
 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']
    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'
    def test_update(self, client):
        """ update should override and add Update 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.update()['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), '')]