コード例 #1
0
 def test_public_publication(self, client):
     """ published with explicit publication date """
     now = timezone.now()
     Type1(node=Node.root(), state="published", expire=None, publication=now - timedelta(hours=1)).save()
     public = Node.objects.public()
     assert public.count() == 1
     assert public[0] == Node.root()
コード例 #2
0
 def test_public_publish(self, client):
     """ published without explicit expire/publication """
     Type1(node=Node.root(), state="published",
           expire=None, publication=None).save()
     public = Node.objects.public()
     assert public.count() == 1
     assert public[0] == Node.root()
コード例 #3
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_preferred_language_children(self, client):
        root = Node.root()
        sub = root.add("sub")

        root = Node.root(language="nl")
        child = root.children()[0]
        assert child.preferred_language == "nl"
コード例 #4
0
ファイル: test_node.py プロジェクト: wheelcms/wheelcms_axle
    def test_node_equality(self, client, root):
        sub = root.add("sub")
        sub_nl = Node.root(language="nl").children()[0]
        sub_en = Node.root(language="en").children()[0]

        assert sub_nl != sub_en
        assert sub_nl != sub

        sub.preferred_language = "nl"
        assert sub == sub_nl
コード例 #5
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
 def test_rename_recursive_similar(self, client):
     """ renaming /aaa should't affect /aaaa """
     aaa = Node.root().add("aaa")
     aaaa = Node.root().add("aaaa")
     aa = Node.root().add("aa")
     bbb = aaaa.add("bbb")
     bb = aa.add("bb")
     aaa.rename("ccc")
     assert Node.objects.get(pk=bbb.pk).path == "/aaaa/bbb"
     assert Node.objects.get(pk=bb.pk).path == "/aa/bb"
コード例 #6
0
    def test_clipboard_copy(self, client):
        root = Node.root()

        t1 = Type1(node=root.add("t1"), title="t1").save()
        t2 = Type1(node=root.add("t2"), title="t2").save()

        request = create_request("GET", "/")
        request.session['clipboard_copy'] = [t2.node.tree_path, t1.node.tree_path]

        toolbar = Toolbar(Node.root(), request, "view")
        clipboard = toolbar.clipboard()
        assert clipboard['count'] == 2
        assert clipboard['copy']
        assert not clipboard['cut']
        assert set(clipboard['items']) == set((t1, t2))
コード例 #7
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
 def test_change_slug_duplicate(self, client):
     """ change a slug """
     aaa = Node.root().add("aaa")
     aaa.add("bbb")
     node = aaa.add("bbb2")
     py.test.raises(DuplicatePathException, node.rename, "bbb")
     assert node.slug() == "bbb2"
コード例 #8
0
 def test_duplicate_content_different_languages(self, client):
     """ two content objects for different languages
          can point to the same node """
     root = Node.root()
     child1 = root.add("n1")
     Type1(node=child1, language="nl").save()
     child1.set(Type1(language="fr").save())
コード例 #9
0
 def test_duplicate_content(self, client):
     """ two content objects for the same language 
          cannot point to the same node """
     root = Node.root()
     child1 = root.add("n1")
     Type1(node=child1, language="nl").save()
     pytest.raises(NodeInUse, lambda: child1.set(Type1(language="nl").save()))
コード例 #10
0
ファイル: test_rss.py プロジェクト: wheelcms/wheelcms_rss
 def test_simple(self, client):
     """ simple case """
     root = Node.root()
     content = Type1(title="Hello World", state="published", node=root).save()
     spoke = content.spoke()
     feed = WheelFeed(spoke)
     assert content.content_ptr in feed.items()
コード例 #11
0
    def test_create_map(self, client):
        root = Node.root()
        r = root.add(langslugs=dict(fr="fr", en="en", nl="nl"))

        assert Node.get("/fr", language="fr") == \
               Node.get("/en", language="en") == \
               Node.get("/nl", language="nl") == r
コード例 #12
0
    def test_node_child(self, client):
        """ test the node.child method """
        translation.activate('en')
        root = Node.root()
        child = root.add("child")

        assert root.child("child") == child
コード例 #13
0
def languages(request):
    if len(settings.LANGUAGES) <= 1:
        return None

    current_language = get_active_language()
    current_label = dict(settings.LANGUAGES).get(current_language,
                                                 current_language)

    res = []

    ld = getattr(settings, 'LANGUAGE_DOMAINS', {})

    for lang, label in settings.CONTENT_LANGUAGES:
        if lang == current_language:
            is_current = True
        else:
            is_current = False

        url = Node.root().get_absolute_url(language=lang)
        has_translation = False

        domain = ld.get(lang)
        if domain:
            protocol = "https" if request.is_secure() else "http"
            url = "%s://%s%s" % (protocol, domain, url)

        res.append(dict(id=lang, label=label, url=url,
                        has_translation=has_translation,
                        is_current=is_current))
    return dict(languages=dict(current=dict(id=current_language, label=current_label),
                languages=res))
コード例 #14
0
 def test_public_before_publication(self, client):
     """ published content before publication """
     now = timezone.now()
     Type1(node=Node.root(), state="published",
           expire=None, publication=now + timedelta(hours=1)).save()
     public = Node.objects.public()
     assert public.count() == 0
コード例 #15
0
 def test_public_past_expire(self, client):
     """ published content past expiration """
     now = timezone.now()
     Type1(node=Node.root(), state="published",
           expire=now - timedelta(hours=1), publication=None).save()
     public = Node.objects.public()
     assert public.count() == 0
コード例 #16
0
 def setup_nodes(self):
     """ A mix of attached/unattached nodes, all unpublished """
     root = Node.root()
     _ = Type1(node=root.add("type1")).save()
     _ = Type1(node=root.add("attached")).save()
     i3 = root.add("unattached")
     _ = Type1(node=i3.add("attached-on-unattached")).save()
コード例 #17
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
 def test_nonroot_child(self, client):
     """ access a child outside the root by its name """
     root = Node.root()
     child = root.add("child")
     child2 = child.add("child")
     # import pytest; pytest.set_trace()
     assert child.child('child') == child2
コード例 #18
0
    def test_translations_create(self, client):
        root = Node.root()

        n = root.add(langslugs=dict(en="en", nl="nl", fr="fr"))
        t_nl = Type1(node=n, language="nl", title="NL").save()
        t_en = Type1(node=n, language="en", title="EN").save()


        request = create_request("GET", "/create", data=dict(type="sometype"))

        translation.activate("en")
        toolbar = Toolbar(n, request, "create")
        translations = toolbar.translations()

        assert translations['active']['id'] == 'en'

        import urllib2

        ## Do some matching magic using endswith to work around language / base prefixing.
        ## We're mosly interested in create/view/edit actions anyway
        assert len(translations['translated']) == 0
        assert len(translations['untranslated']) == 3  ## all languages incl 'any', active lang excluded

        for ut in translations['untranslated']:
            l = ut['id']
            assert l in ('nl', 'fr', 'en', 'any')
            assert ut['action_url'].endswith('switch_admin_language?path='+n.tree_path + '&switchto=' + l + '&rest=' + urllib2.quote('create?type=sometype'))
コード例 #19
0
    def test_no_implicit_unattached(self, client):
        """ An unattached node cannot restrict its children but
            should still not allow creation of non-implicit_add
            types """

        class DummyContent(object):
            meta_type = 'dummycontent'

            @classmethod
            def get_name(cls):
                return "test." + cls.meta_type

        class DummyType(Spoke):
            model = DummyContent
            children = ()
            implicit_add = False

            @classmethod
            def title(cls):
                return ''

        self.registry.register(DummyType)


        node = Node.root()
        toolbar = Toolbar(node, superuser_request("/"), "view")
        for c in toolbar.children():
            assert c['name'] != DummyType.name()
コード例 #20
0
 def test_clipboard_empty(self, client):
     toolbar = Toolbar(Node.root(), superuser_request("/"), "view")
     clipboard = toolbar.clipboard()
     assert clipboard['count'] == 0
     assert not clipboard['copy']
     assert not clipboard['cut']
     assert clipboard['items'] == []
コード例 #21
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
 def test_preferred_language_child(self, client):
     root = Node.root()
     sub = root.add("sub")
     sub_pref = root.child("sub", language="en")
     assert sub_pref.preferred_language == "en"
     sub_pref = root.child("sub", language="nl")
     assert sub_pref.preferred_language == "nl"
コード例 #22
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_copy_node_to_self(self, client):
        """ copy /foo to / """
        root = Node.root()
        src = root.add("src")
        res, success, failed = root.paste(src, copy=True)

        assert res.path != "/src"
コード例 #23
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_move_inside_offspring(self, client):
        """ A node cannot be moved to one of its offspring nodes. """
        root = Node.root()
        src = root.add("src")
        target = src.add("target")

        py.test.raises(CantMoveToOffspring, target.paste, src)
コード例 #24
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
 def test_change_slug(self, client):
     """ change a slug """
     node = Node.root().add("aaa").add("bbb")
     assert node.slug() == "bbb"
     node.rename("ccc")
     node = Node.objects.get(pk=node.pk)
     assert node.slug() == "ccc"
     assert node.path == "/aaa/ccc"
コード例 #25
0
    def test_nosu_no_settings(self, client):
        user, _ = User.objects.get_or_create(username="******")
        request = create_request("GET", "/")
        request.user = user

        node = Node.root()
        toolbar = Toolbar(node, request, "view")
        assert not toolbar.show_settings()
コード例 #26
0
 def test_update_mode_buttons(self, client):
     """ verify that certain buttons are not shown in update mode """
     node = Node.root()
     content = Type1(node=node)
     content.save()
     toolbar = Toolbar(node, superuser_request("/"), "update")
     assert not toolbar.show_create()
     assert not toolbar.show_update()
コード例 #27
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_unique(self, client):
        """ paths are unique, you cannot add  the same name twice """
        root = Node.root()
        root.add("child")

        py.test.raises(DuplicatePathException, root.add, "child")
        py.test.raises(DuplicatePathException, root.add, "CHILD")
        py.test.raises(DuplicatePathException, root.add, "Child")
コード例 #28
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_remove_single_root(self, client):
        """ single, non-recursive removal """
        root = Node.root()
        root.add("aaa")
        assert Node.get("/aaa")

        root.remove("aaa")
        assert not Node.get("/aaa")
コード例 #29
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_move_to_self(self, client):
        """ moving /foo to / """
        root = Node.root()
        src = root.add("src")
        res, success, failed = root.paste(src)

        assert res == src
        assert res.path == "/src"
コード例 #30
0
ファイル: test_node.py プロジェクト: reichertwd/wheelcms_axle
    def test_remove_ignore_similar(self, client):
        """ removing /aaa shouldn't affect /aaaa """
        root = Node.root()
        root.add("aaa")
        root.add("aaaa")

        root.remove("aaa")
        assert Node.get("/aaaa")