• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factory.create_structureNode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中node_storage.factory.create_structureNode函数的典型用法代码示例。如果您正苦于以下问题:Python create_structureNode函数的具体用法?Python create_structureNode怎么用?Python create_structureNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_structureNode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_add_derivate_copies_arguments

    def test_add_derivate_copies_arguments(self):
        s = create_structureNode("Source", authors=[self.hans])
        self.foo.append_child(s)
        d = create_structureNode("Derivate", authors=[self.hans])
        self.foo.append_child(d)
        a = create_argument(s, arg_type='p', title="myArg", text="cool",
                            authors=[self.hugo])
        self.assertEqual(s.arguments.count(), 1)
        self.assertEqual(s.arguments.all()[0], a)
        s.add_derivate(d, arg_type='c', title="yourArg", text="ument",
                       authors=[self.hans])
        self.assertEqual(s.arguments.count(), 2)
        sa1, sa2 = s.arguments.order_by('index')
        self.assertEqual(sa1, a)
        self.assertEqual(sa2.arg_type, 'c')
        self.assertEqual(sa2.title, 'yourArg')
        self.assertEqual(sa2.text.text, 'ument')
        self.assertEqual(sa2.text.authors.count(), 1)
        self.assertIn(self.hans, sa2.text.authors.all())

        self.assertEqual(d.arguments.count(), 1)
        da1, = d.arguments.order_by('index')
        self.assertEqual(da1.arg_type, 'p')
        self.assertEqual(da1.title, 'myArg')
        self.assertEqual(da1.text.text, 'cool')
        self.assertEqual(da1.text.authors.count(), 1)
        self.assertIn(self.hugo, da1.text.authors.all())
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:27,代码来源:test_node.py


示例2: test_get_unfollows_with_an_unfollow_returns_1

 def test_get_unfollows_with_an_unfollow_returns_1(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n])
     create_vote(self.hugo, [n, n2])
     self.assertEqual(n2.get_unfollows(), 1)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:7,代码来源:test_node.py


示例3: test_get_newfollows_does_count_votes_and_not_users

 def test_get_newfollows_does_count_votes_and_not_users(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n])
     create_vote(self.hans, [n2])
     self.assertEqual(n2.get_newfollows(), 1)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:7,代码来源:test_node.py


示例4: setUp

 def setUp(self):
     self.n = create_structureNode("woot")
     self.n1 = create_structureNode("foo1")
     self.n2 = create_structureNode("foo2")
     self.n1.add_derivate(self.n2)
     self.hugo = create_user("hugo")
     self.v = create_vote(self.hugo, [self.n1, self.n2])
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:7,代码来源:test_view_helpers.py


示例5: test_get_newfollows_with_2_newfollows_returns_2

 def test_get_newfollows_with_2_newfollows_returns_2(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n2])
     create_vote(self.hugo, [n2])
     self.assertEqual(n2.get_newfollows(), 2)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:7,代码来源:test_node.py


示例6: test_get_newfollows_on_node_with_same_votes_than_source_returns_0

 def test_get_newfollows_on_node_with_same_votes_than_source_returns_0(self):
     n = create_structureNode('Foo')
     n2 = create_structureNode('Foo2')
     n.add_derivate(n2)
     create_vote(self.hans, [n, n2])
     create_vote(self.hugo, [n, n2])
     self.assertEqual(n2.get_newfollows(), 0)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:7,代码来源:test_node.py


示例7: test_get_unfollows_counts_votes_from_multiple_sources_only_once

 def test_get_unfollows_counts_votes_from_multiple_sources_only_once(self):
     n1 = create_structureNode('Foo1')
     n2 = create_structureNode('Foo2')
     d = create_structureNode('Foo12')
     n1.add_derivate(d)
     n2.add_derivate(d)
     create_vote(self.hans, [n1, n2])
     self.assertEqual(d.get_unfollows(), 1)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:8,代码来源:test_node.py


示例8: test_add_derivate_creates_commit_argument

 def test_add_derivate_creates_commit_argument(self):
     s = create_structureNode("Source", authors=[self.hans])
     self.foo.append_child(s)
     d = create_structureNode("Derivate", authors=[self.hans])
     self.foo.append_child(d)
     s.add_derivate(d, arg_type='c', title="arg", text="ument",
                    authors=[self.hugo])
     no = Derivation.objects.filter(source=s, derivate=d)
     self.assertTrue(no.count() == 1)
     no = no[0]
     self.assertEqual(no.argument.arg_type, 'c')
     self.assertEqual(no.argument.title, 'arg')
     self.assertEqual(no.argument.text.text, 'ument')
     self.assertEqual(no.argument.text.authors.count(), 1)
     self.assertIn(self.hugo, no.argument.text.authors.all())
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:15,代码来源:test_node.py


示例9: test_add_derivate_adds_only_correct_derivation

    def test_add_derivate_adds_only_correct_derivation(self):
        n = create_structureNode("Source", authors=[self.hans])
        self.foo.append_child(n)
        d = create_structureNode("Derivate", authors=[self.hans])
        self.foo.append_child(d)

        n.add_derivate(d, arg_type='n')
        self.assertIn(d, n.derivates.all())
        self.assertIn(n, d.sources.all())

        no = Derivation.objects.filter(source=n, derivate=d)
        self.assertTrue(no.count() == 1)
        self.assertEqual(n, no.all()[0].argument.concerns)
        self.assertIn(no[0], n.derivative_order_set.all())
        self.assertIn(no[0], d.source_order_set.all())
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:15,代码来源:test_node.py


示例10: setUp

 def setUp(self):
     self.max = create_user('max')
     self.root = get_root_node()
     self.bla = create_slot("Bla")
     self.root.append_child(self.bla)
     self.bla1 = create_structureNode('Bla ist Bla',
                                      "Das musste gesagt werden.",
                                      [self.max])
     self.bla.append_child(self.bla1)
     self.blubb = create_slot("Blubb")
     self.bla1.append_child(self.blubb)
     self.blubb1 = create_textNode("Blubb ist eins", "Gesagt ist gedacht.",
                                   [self.max])
     self.blubb.append_child(self.blubb1)
     self.blubb2 = create_textNode("Blubb die Zweite",
                                   "Geschrieben ist notiert.", [self.max])
     self.blubb.append_child(self.blubb2)
     self.blubb2d = create_textNode("Blubb die Zweite",
                                    "Geschrieben ist anders notiert.",
                                    [self.max])
     self.blubb.append_child(self.blubb2d)
     self.blubb2.add_derivate(self.blubb2d)
     self.bla2 = create_textNode("Follopp", "Globbern!", [self.max])
     self.bla.append_child(self.bla2)
     self.bla2.add_derivate(self.blubb2)
     self.bla3 = create_textNode("Folloppiii", "Globbern! Den ganzen Tag.",
                                 [self.max])
     self.bla.append_child(self.bla3)
     self.blubb2.add_derivate(self.bla3)
     self.bla4 = create_textNode("Flop", "Glob!", [self.max])
     self.bla.append_child(self.bla4)
     self.bla3.add_derivate(self.bla4)
开发者ID:justelex,项目名称:Findeco,代码行数:32,代码来源:test_load_graph_data.py


示例11: setUp

    def setUp(self):
        self.hans = create_user('hans')
        self.hugo = create_user('hugo')

        self.root = get_root_node()
        self.slot1 = create_slot('Wahlprogramm')
        self.root.append_child(self.slot1)
        self.structureNode1 = create_structureNode('LangerWahlprogrammTitel',
                                                   authors=[self.hans])
        self.slot1.append_child(self.structureNode1)
        self.slot11 = create_slot('Transparenz')
        self.structureNode1.append_child(self.slot11)
        self.textnode11 = create_textNode('Traaaansparenz', authors=[self.hans])
        self.slot11.append_child(self.textnode11)
        self.slot12 = create_slot('Bildung')
        self.structureNode1.append_child(self.slot12)
        self.textnode12 = create_textNode('Biiildung', authors=[self.hans])
        self.slot12.append_child(self.textnode12)
        self.slot13 = create_slot('Datenschutz')
        self.structureNode1.append_child(self.slot13)
        self.textnode13 = create_textNode('Daaatenschutz', authors=[self.hans])
        self.slot13.append_child(self.textnode13)

        self.arguments = []
        for i in range(1, 25):
            arg = create_argument(self.textnode11, 'p', "Argument" + str(i),
                                  "Text of argument no. " + str(i), [self.hugo, self.hans])
            create_vote(self.hugo, [arg])
            if i % 2 == 1:
                create_vote(self.hans, [arg])
                create_spam_flag(self.hugo, [arg])
            self.arguments.append(arg)
开发者ID:Qwlouse,项目名称:Findeco,代码行数:32,代码来源:test_load_argument_news.py


示例12: generate_refinement

def generate_refinement(origin, proposal, argument, slot, user):
    derivate = create_structureNode(
        long_title=proposal['heading'], text=proposal['text'], authors=[user])
    slot.append_child(derivate)

    create_vote(user, [derivate])  # auto-follow

    for child in proposal['subsections']:
        if not re.match(SHORT_TITLE, child['shorttitle']):
            raise InvalidShortTitle('Invalid short-title: "{}"'.
                                    format(child['shorttitle']))
        if 'text' in child:
            if origin.children.filter(title=child['shorttitle']).count() > 0:
                raise InvalidShortTitle('ShortTitle {} is already taken'.
                                        format(child['shorttitle']))
            child_slot = create_slot(child['shorttitle'])
            derivate.append_child(child_slot)
            generate_proposal_node_with_subsections(child_slot, child, user)
        else:
            child_slots = origin.children.filter(title=child['shorttitle'])
            if child_slots.count() == 0:
                raise InvalidShortTitle('Unknown short title {}'.
                                        format(child['shorttitle']))
            derivate.append_child(child_slots[0])
    origin.add_derivate(derivate,
                        arg_type="con",
                        title=argument['heading'],
                        text=argument['text'],
                        authors=[user])
    return derivate
开发者ID:Qwlouse,项目名称:Findeco,代码行数:30,代码来源:view_helpers.py


示例13: test_add_derivate

    def test_add_derivate(self):
        n = create_structureNode("Source", authors=[self.hans])
        d = create_structureNode("Derivate", authors=[self.hans])
        a = create_argument()
        n.add_derivate(a, d)


        self.assertIn(d, n.derivates.all())
        self.assertIn(n, d.sources.all())

        no = Derivation.objects.filter(source=n, derivate=d)
        self.assertTrue(no.count() == 1)
        self.assertEqual(no[0].argument, a)

        self.assertIn(no[0], n.derivative_order_set.all())
        self.assertIn(no[0], d.source_order_set.all())
开发者ID:FrankWalle,项目名称:Findeco,代码行数:16,代码来源:test_node.py


示例14: test_append_child_slot_adds_all_paths

    def test_append_child_slot_adds_all_paths(self):
        slot = create_slot('Foo')
        self.root.append_child(slot)
        sn1 = create_structureNode("Foobarbaz1")
        slot.append_child(sn1)
        sn2 = create_structureNode("Foobarbaz2")
        slot.append_child(sn2)
        slot_t = create_slot('Ba')
        sn1.append_child(slot_t)
        sn2.append_child(slot_t)

        sn_test = create_structureNode("Barbaren")
        slot_t.append_child(sn_test)

        self.assertEqual(sn_test, PathCache.objects.get(path='Foo.1/Ba.1').node)
        self.assertEqual(sn_test, PathCache.objects.get(path='Foo.2/Ba.1').node)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:16,代码来源:test_nodepath_cache.py


示例15: fork_node_and_add_slot

def fork_node_and_add_slot(path, user, wiki_text):
    source_node = assert_node_for_path(path)
    authors = list(source_node.text.authors.all()) + [user]
    title = source_node.title
    # create fork
    fork = create_structureNode(title,
                                source_node.text.text,
                                authors)
    parent_slot_path = path.rsplit('.', 1)[0]
    parent_slot = get_node_for_path(parent_slot_path)
    parent_slot.append_child(fork)
    fork_path = parent_slot_path + '.' + str(fork.get_index(parent_slot))
    short_titles = set()
    for slot in get_ordered_children_for(source_node):
        fork.append_child(slot)
        short_titles.add(slot.title)
    # create new slot plus node
    schema = parse(wiki_text, 'foo')
    short_title = turn_into_valid_short_title(schema['title'], short_titles)
    new_slot = create_slot(short_title)
    fork.append_child(new_slot)
    node = create_structure_from_structure_node_schema(schema, new_slot, user)
    arg_title = "Abschnitt über '{0}' fehlt.".format(schema['title'])
    source_node.add_derivate(fork, 'con', arg_title, authors=[user])
    # auto follow
    follow_node(fork, user.id)
    follow_node(node, user.id)
    return fork_path
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:28,代码来源:view_helpers.py


示例16: test_add_derivate_creates_transitive_votes

    def test_add_derivate_creates_transitive_votes(self):
        n = create_structureNode("Source", authors=[self.hans])
        self.foo.append_child(n)
        v1 = create_vote(self.hans, [n])
        v2 = create_vote(self.hugo, [n])
        d = create_structureNode("Derivate", authors=[self.hans])
        self.foo.append_child(d)
        n.add_derivate(d, arg_type='n')

        self.assertIn(n, v1.nodes.all())
        self.assertIn(d, v1.nodes.all())
        self.assertEqual(v1.nodes.count(), 2)
        self.assertIn(n, v2.nodes.all())
        self.assertIn(d, v2.nodes.all())
        self.assertEqual(v2.nodes.count(), 2)
        self.assertEqual(d.votes.count(), 2)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:16,代码来源:test_node.py


示例17: create_alternatives_for_urheberrecht

def create_alternatives_for_urheberrecht(path):
    ulf = create_user("ulf")
    timo = create_user("timo")
    slot_path = path.rsplit(".", 1)[0]
    slot = get_node_for_path(slot_path)

    w1 = "Reform des Urheberrechts sollte von der Basis kommen."

    a1 = create_structureNode("Urheberrecht", w1, authors=[ulf])
    slot.append_child(a1)

    w2a = "Abschaffung des Urheberrechts!"
    a2a = create_structureNode("Kein Urheberrecht", w2a, authors=[ulf])
    slot.append_child(a2a)

    w2b = "Völlige Abschaffung des Urheber- und Patentrechts!"
    a2b = create_structureNode("Kein Urheberrecht", w2b, authors=[ulf])
    slot.append_child(a2b)
    arga = a2a.add_derivate(
        a2b,
        "con",
        "Patentrecht ist genauso böse",
        "Das patentrecht ist mindestens genauso schlimm und muss auch weg!",
        [ulf],
    )

    w2c = "Völlige Abschaffung des Urheber- und Patentrechts! Außerdem Todesstrafe für alle Patentanwälte."
    a2c = create_structureNode("Kein Urheberrecht", w2c, authors=[timo])
    slot.append_child(a2c)
    argb = a2b.add_derivate(a2c, "con", "Patentanwälte stinken!", "Dieses Pack gehört ausgerottet!", [timo])

    # create votes
    original = get_node_for_path(path)
    hugo = create_user("hugo")
    hans = create_user("hans")
    hein = create_user("hein")
    create_vote(ulf, [a1])
    create_vote(ulf, [a2a, a2b])
    create_vote(timo, [a2c])
    create_vote(hugo, [original])
    create_vote(hein, [original])
    create_vote(hans, [a1])
    create_vote(hans, [a2b])
    create_vote(hans, [arga])
    create_vote(ulf, [arga])
    create_spam_flag(hein, [argb])
    create_spam_flag(hein, [a2c])
开发者ID:justelex,项目名称:Findeco,代码行数:47,代码来源:initial_data.py


示例18: test_append_child_structure_node_adds_to_path_cache

    def test_append_child_structure_node_adds_to_path_cache(self):
        slot = create_slot('Foo')
        self.root.append_child(slot)
        sn = create_structureNode("Foobarbaz")
        slot.append_child(sn)

        self.assertEqual(sn, PathCache.objects.get(path='Foo.1').node)
        self.assertEqual('Foo.1', PathCache.objects.get(node=sn).path)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:8,代码来源:test_nodepath_cache.py


示例19: test_creating_an_argument_adds_to_path_cache

    def test_creating_an_argument_adds_to_path_cache(self):
        slot = create_slot('Foo')
        self.root.append_child(slot)
        sn = create_structureNode("Foobarbaz1")
        slot.append_child(sn)

        a = create_argument(sn, arg_type='con')
        node_a = Node.objects.get(id=a.id)
        self.assertEqual(node_a, PathCache.objects.get(path='Foo.1.con.1').node)
开发者ID:Lhurgoyfina,项目名称:Findeco,代码行数:9,代码来源:test_nodepath_cache.py


示例20: setUp

    def setUp(self):
        self.horst = create_user('horst')
        self.udo = create_user('udo')

        self.root = get_root_node()
        self.slot1 = create_slot('soon_empty')
        self.root.append_child(self.slot1)
        self.node = create_structureNode('To be or not to be', 'never both')
        self.slot1.append_child(self.node)
        self.arg = create_argument(self.node, 'c', "no", "lyrics")
        self.path = 'soon_empty.1'
        self.child_slot = create_slot('or_to_pee')
        self.node.append_child(self.child_slot)
        self.child = create_structureNode('or to pee')
        self.child_slot.append_child(self.child)

        TextCache.objects.create(path=self.path, paragraphs="doesn't matter")
        IndexCache.objects.create(path=self.path, index_nodes="doesn't matter")

        self.slot2 = create_slot('verfassungswiedrig')
        self.root.append_child(self.slot2)
        self.source = create_structureNode('BöserTitel', 'gewöhnlicher text')
        self.slot2.append_child(self.source)
        self.derivate = create_structureNode('BöserTitel',
                                             'verfassungswiedriger text')
        self.slot2.append_child(self.derivate)
        self.source.add_derivate(self.derivate, arg_type='con',
                                 title="zuSchwach", text="muss fieser werden",
                                 authors=[self.udo])

        self.source_path = 'verfassungswiedrig.1'
        self.derivate_path = 'verfassungswiedrig.2'

        create_vote(self.udo, [self.node])
        create_vote(self.horst, [self.source, self.node])
        create_spam_flag(self.horst, [self.node])

        create_post('i reference /verfassungswiedrig.1 because i like it ',
                    self.horst, self.path)
开发者ID:Qwlouse,项目名称:Findeco,代码行数:39,代码来源:test_tools.py



注:本文中的node_storage.factory.create_structureNode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.create_user函数代码示例发布时间:2022-05-27
下一篇:
Python node_manager_fkie.ssh函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap