当前位置: 首页>>代码示例>>Python>>正文


Python factory.create_structureNode函数代码示例

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


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


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