本文整理汇总了Python中node_storage.factory.create_vote函数的典型用法代码示例。如果您正苦于以下问题:Python create_vote函数的具体用法?Python create_vote怎么用?Python create_vote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_vote函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: 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)
示例3: test_load_microblogging_for_followed_nodes
def test_load_microblogging_for_followed_nodes(self):
create_nodes_for_path("foo.1")
foo2 = create_nodes_for_path("foo.2")
foo1bar1 = create_nodes_for_path("foo.1/bar.1")
hugo = create_user("hugo")
create_vote(hugo, [foo2])
create_vote(hugo, [foo1bar1])
posts = [create_post("posted at node", hugo, location='foo.2'),
create_post("reference /foo.2", hugo, location=''),
create_post("reference /foo.1/bar.1", hugo, location='foo.2')]
wrong_posts = [create_post("posted somewhere", hugo, location='foo.1'),
create_post("reference wrong /foo.1", hugo, location=''),
create_post("neither", hugo, location='')]
response = self.client.get(
reverse('load_microblogging_for_followed_nodes',
kwargs={'name': 'hugo'}))
res = json.loads(response.content)["loadMicrobloggingResponse"]
response_id_list = [m["microblogID"] for m in res]
for post in posts:
self.assertIn(post.id, response_id_list)
for post in wrong_posts:
self.assertNotIn(post.id, response_id_list)
self.assertEqual(len(res), 3)
示例4: 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)
示例5: 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
示例6: 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.textnode1 = create_textNode('LangerWahlprogrammTitel',
authors=[self.hans])
self.slot1.append_child(self.textnode1)
self.slot2 = create_slot('Grundsatzprogramm')
self.root.append_child(self.slot2)
self.textnode2 = create_textNode('LangerGrundsatzTitel',
authors=[self.hugo])
self.slot2.append_child(self.textnode2)
self.slot3 = create_slot('Organisatorisches')
self.root.append_child(self.slot3)
self.textnode31 = create_textNode('Langweilig1', authors=[self.hans])
self.textnode32 = create_textNode('Langweilig2', authors=[self.hugo])
self.textnode33 = create_textNode('Langweilig3',
authors=[self.hans, self.hugo])
self.slot3.append_child(self.textnode31)
self.slot3.append_child(self.textnode32)
self.slot3.append_child(self.textnode33)
create_vote(self.hans, [self.textnode33])
self.top_slots = [self.slot1, self.slot2, self.slot3]
self.short_titles = ['Wahlprogramm', 'Grundsatzprogramm',
'Organisatorisches']
self.full_titles = ['LangerWahlprogrammTitel', 'LangerGrundsatzTitel',
'Langweilig3']
self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
示例7: 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)
示例8: 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)
示例9: 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)
示例10: store_structure_node
def store_structure_node(path, wiki_text, author):
slot_path = path.rsplit('.', 1)[0]
slot = get_node_for_path(slot_path)
structure = backend.parse(wiki_text, None)
structure_node = backend.create_structure_from_structure_node_schema(
structure, slot, [author])
# add auto follow
create_vote(author, [structure_node])
return structure_node, get_good_path_for_structure_node(structure_node,
slot, slot_path)
示例11: store_derivate
def store_derivate(path, arg_text, arg_type, derivate_wiki_text, author):
new_node, new_path = store_structure_node(path, derivate_wiki_text, author)
node = get_node_for_path(path)
arg_title, arg_text = backend.split_title_from_text(arg_text)
arg = node.add_derivate(new_node, arg_type=arg_type,
title=arg_title,
text=arg_text, authors=[author])
# add auto follow
create_vote(author, [arg])
return new_path
示例12: store_argument
def store_argument(path, arg_text, arg_type, author):
node = get_node_for_path(path)
title, arg_text = backend.split_title_from_text(arg_text)
original_argument = create_argument(node, arg_type, title, arg_text,
[author])
# add auto follow
create_vote(author, [original_argument])
# copy argument for all derivates
for d in node.traverse_derivates():
new_argument = create_argument(d, arg_type, title, arg_text, [author])
original_argument.add_derivate(new_argument)
return path + "." + arg_type + "." + str(node.arguments.count())
示例13: store_structure_node
def store_structure_node(path, wiki_text, author, argument=None):
slot_path = path.rsplit('.', 1)[0]
slot = get_node_for_path(slot_path)
structure_schema = backend.parse(wiki_text, None)
clone_candidates = None
if argument:
clone_candidates = slot.children.all()
structure_node = backend.create_structure_from_structure_node_schema(
structure_schema, slot, author, clone_candidates)
# add auto follow
create_vote(author, [structure_node])
return structure_node, get_good_path_for_structure_node(structure_node,
slot, slot_path)
示例14: generate_proposal_node_with_subsections
def generate_proposal_node_with_subsections(slot, proposal, user):
proposal_node = create_structureNode(
long_title=proposal['heading'], text=proposal['text'], authors=[user])
slot.append_child(proposal_node)
create_vote(user, [proposal_node]) # auto-follow
for child in proposal['subsections']:
if not re.match(SHORT_TITLE, child['shorttitle']):
raise InvalidShortTitle('Invalid short-title: "{}"'.
format(child['shorttitle']))
child_slot = create_slot(child['shorttitle'])
proposal_node.append_child(child_slot)
generate_proposal_node_with_subsections(child_slot, child, user)
return proposal_node
示例15: setUp
def setUp(self):
self.root = get_root_node()
self.hugo = create_user("Hugo", password="1234", groups=['voters'])
self.ulf = create_user("Ulf", password="abcde", groups=['voters'])
self.permela = create_user("Permela", password="xxx")
self.slot = create_slot("Slot")
self.root.append_child(self.slot)
self.text = create_textNode("Bla", "Blubb", [self.hugo])
self.slot.append_child(self.text)
self.mid = create_textNode("Bla derivate", "Blubb2", [self.hugo])
self.slot.append_child(self.mid)
self.text.add_derivate(self.mid, arg_type='c', title="dagegen")
self.leaf1 = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
self.slot.append_child(self.leaf1)
self.mid.add_derivate(self.leaf1, arg_type='c', title="dagegen2")
self.mid2 = create_textNode("Bla derivate 2", "Blubb4", [self.hugo])
self.slot.append_child(self.mid2)
self.mid.add_derivate(self.mid2, arg_type='c', title="dagegen")
self.leaf2 = create_textNode("Bla leaf 2", "Blubb5", [self.hugo])
self.slot.append_child(self.leaf2)
self.mid2.add_derivate(self.leaf2, arg_type='c', title="dagegen")
self.follow = create_vote(self.hugo,
[self.text, self.mid, self.leaf1, self.mid2,
self.leaf2])
self.arg1 = create_argument(self.text, "con", "Wrong!", "Bad!",
[self.hugo])