Esempio n. 1
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.ulf = create_user("Ulf", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     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])
    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)
Esempio n. 3
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.ulf = create_user("Ulf", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     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])
Esempio n. 4
0
    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]]
Esempio n. 5
0
    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]]
Esempio n. 6
0
    def test_load_microblogging_from_user(self):
        hugo = create_user("hugo")
        herbert = create_user("herbert")

        posts = [
            create_post("@hugo ", herbert, location=''),
            create_post("@herbert @hugo", herbert, location='')
        ]

        wrong_posts = [
            create_post("no mentions", hugo, location=''),
            create_post("@herbert", hugo, location='')
        ]

        response = self.client.get(
            reverse('load_microblogging_from_user', kwargs={'name':
                                                            'herbert'}))
        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), 2)
Esempio n. 7
0
 def setUp(self):
     self.hans = create_user('hans')
     self.herbert = create_user('herbert')
     self.hein = create_user('hein')
     self.hans.profile.blocked.add(self.herbert.profile)
     self.hein.profile.blocked.add(self.herbert.profile)
     self.users = [self.hans, self.herbert, self.hein]
Esempio n. 8
0
    def test_load_microblogging_for_authored_nodes(self):
        hugo = create_user('hugo')
        herbert = create_user('herbert')

        create_nodes_for_path("foo.1", authors=[herbert])
        create_nodes_for_path("foo.2", authors=[hugo])
        create_nodes_for_path("foo.1/bar.1", authors=[hugo, herbert])

        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_authored_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)
Esempio n. 9
0
 def test_mail_notify_new_argument(self):
     hugo = create_user("hugo")
     hugo.email = "*****@*****.**"
     hugo.profile.wants_mail_notification = True
     hugo.save()
     max = create_user("max")
     max.email = "*****@*****.**"
     max.profile.wants_mail_notification = True
     max.save()
     berta = create_user("berta")
     berta.email = "*****@*****.**"
     berta.profile.wants_mail_notification = False
     berta.save()
     post = create_post('System Message', hugo)
     node = create_nodes_for_path('/foo.1', [hugo])
     create_vote(hugo, [node])
     create_vote(max, [node])
     create_vote(berta, [node])
     create_argument(node, 'n', 'Bla', 'Blubb', [hugo])
     notify_new_argument(node, post)
     self.assertEqual(len(mail.outbox), 1)
     m = mail.outbox[0]
     self.assertEqual(m.to, [])
     self.assertEqual(m.bcc, ['*****@*****.**', '*****@*****.**'])
     self.assertIn('System Message', m.body)
     self.assertGreater(len(m.subject), 0)
Esempio n. 10
0
    def test_load_microblogging_for_authored_nodes(self):
        hugo = create_user('hugo')
        herbert = create_user('herbert')

        create_nodes_for_path("foo.1", authors=[herbert])
        create_nodes_for_path("foo.2", authors=[hugo])
        create_nodes_for_path("foo.1/bar.1", authors=[hugo, herbert])

        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_authored_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)
Esempio n. 11
0
    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)
Esempio n. 12
0
    def setUp(self):
        self.hans = create_user('hans', "he's a jolly good fellow")
        self.hugo = create_user('hugo', "nodescription")
        self.hein = create_user('hein', "password1")
        self.users = [self.hans, self.hugo, self.hein]

        self.hugo.profile.followees.add(self.hans.profile)
        self.hein.profile.followees.add(self.hans.profile)
Esempio n. 13
0
    def setUp(self):
        self.hans = create_user('hans', "he's a jolly good fellow")
        self.hugo = create_user('hugo', "nodescription")
        self.hein = create_user('hein', "password1")
        self.users = [self.hans, self.hugo, self.hein]

        self.hugo.profile.followees.add(self.hans.profile)
        self.hein.profile.followees.add(self.hans.profile)
Esempio n. 14
0
 def setUp(self):
     self.hans = create_user('hans')
     self.herbert = create_user('herbert')
     self.hein = create_user('hein')
     self.hugo = create_user('hugo', "nodescription")
     self.hans.profile.blocked.add(self.herbert.profile)
     self.hein.profile.blocked.add(self.herbert.profile)
     self.hugo.profile.followees.add(self.hans.profile)
     self.hein.profile.followees.add(self.hans.profile)
     self.users = [self.hans, self.herbert, self.hein]
Esempio n. 15
0
 def setUp(self):
     self.hans = create_user('hans')
     self.herbert = create_user('herbert')
     self.hein = create_user('hein')
     self.hugo = create_user('hugo', "nodescription")
     self.hans.profile.blocked.add(self.herbert.profile)
     self.hein.profile.blocked.add(self.herbert.profile)
     self.hugo.profile.followees.add(self.hans.profile)
     self.hein.profile.followees.add(self.hans.profile)
     self.users = [self.hans, self.herbert, self.hein]
Esempio n. 16
0
    def setUp(self):
        self.root = get_root_node()
        self.hugo = create_user("Hugo", password="******",
                                groups=['texters', 'voters', 'bloggers'])

        create_user("Notpermitted", password="******")
        self.slot = create_slot("Slot")
        self.root.append_child(self.slot)
        self.text = create_textNode("Slotteria", "This is a textnode",
                                    authors=[self.hugo])
        self.slot.append_child(self.text)
        self.url = reverse('store_text', kwargs=dict(path="Slot.1"))
Esempio n. 17
0
    def test_change_microblogging_authorship_updates_template_text(self):
        hugo = create_user('hugo')
        create_user('herbert')
        arno = create_user('arno')

        post = create_post('hallo @hugo ich bins @herbert!', hugo)
        post.save()
        self.assertEqual(post.text_template, 'hallo {u0} ich bins {u1}!')
        change_microblogging_authorship(hugo, arno)
        post = Post.objects.get(id=post.id)  # update object from DB

        self.assertEqual(post.text_template, 'hallo {u1} ich bins {u0}!')
Esempio n. 18
0
    def test_change_microblogging_authorship_updates_mentions(self):
        hugo = create_user('hugo')
        create_user('herbert')
        arno = create_user('arno')

        post = create_post('hallo @hugo ich bins @herbert!', hugo)
        post.save()

        change_microblogging_authorship(hugo, arno)
        post = Post.objects.get(id=post.id)  # update object from DB

        self.assertNotIn(hugo, post.mentions.all())
        self.assertIn(arno, post.mentions.all())
Esempio n. 19
0
    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.textnode32d = create_textNode('Langweilig2 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode32d)
        self.textnode32.add_derivate(self.textnode32d)
        create_vote(self.hans, [self.textnode32, self.textnode32d])
        self.slot3.append_child(self.textnode33)
        self.textnode33d = create_textNode('Langweilig3 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode33d)
        self.textnode33.add_derivate(self.textnode33d)
        create_spam_flag(self.hugo, [self.textnode33d])
        create_vote(self.hans, [self.textnode33])
        self.nodes = [self.textnode31, self.textnode32, self.textnode32d,
                      self.textnode33, self.textnode33d]
        self.authorGroups = [[create_user_info(self.hans)],
                             [create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)]]
        self.follows = [0, 1, 1, 1, 0]
        self.spamFlags = [0, 0, 0, 0, 1]
        self.unFollows = [0, 0, 0, 0, 1]
        self.newFollows = [0, 1, 0, 1, 0]
        self.originGroups = [[], [], ['Organisatorisches.2'], [],
                             ['Organisatorisches.4']]
Esempio n. 20
0
    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.textnode32d = create_textNode('Langweilig2 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode32d)
        self.textnode32.add_derivate(self.textnode32d)
        create_vote(self.hans, [self.textnode32, self.textnode32d])
        self.slot3.append_child(self.textnode33)
        self.textnode33d = create_textNode('Langweilig3 anders',
                                           authors=[self.hans, self.hugo])
        self.slot3.append_child(self.textnode33d)
        self.textnode33.add_derivate(self.textnode33d)
        create_spam_flag(self.hugo, [self.textnode33d])
        create_vote(self.hans, [self.textnode33])
        self.nodes = [self.textnode31, self.textnode32, self.textnode32d,
                      self.textnode33, self.textnode33d]
        self.authorGroups = [[create_user_info(self.hans)],
                             [create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)],
                             [create_user_info(self.hans),
                              create_user_info(self.hugo)]]
        self.follows = [0, 1, 1, 1, 0]
        self.spamFlags = [0, 0, 0, 0, 1]
        self.unFollows = [0, 0, 0, 0, 1]
        self.newFollows = [0, 1, 0, 1, 0]
        self.originGroups = [[], [], ['Organisatorisches.2'], [],
                             ['Organisatorisches.4']]
Esempio n. 21
0
    def test_load_microblogging_all_loads_all_microblogging(self):
        hugo = create_user("hugo")
        herbert = create_user("herbert")
        create_nodes_for_path("foo.1")
        posts = [create_post("text", hugo, location=''),
                 create_post("text3", hugo, location='foo.1'),
                 create_post("text2", herbert, location='foo.1')]
        response = self.client.get(reverse('load_microblogging_all'))
        res = json.loads(response.content)["loadMicrobloggingResponse"]

        ids = [m["microblogID"] for m in res]
        for p in posts:
            self.assertIn(p.id, ids)
        self.assertEqual(len(res), 3)
Esempio n. 22
0
 def setUp(self):
     self.hans = create_user('hans', description='noneSoFar',
                             password="******")
     self.karl = create_user('karl', description='none',
                             password="******")
     self.anon = User.objects.filter(username='******').all()[0]
     self.slot = create_slot("test")
     self.text1 = create_textNode("Hans Text", "Ich werde anonymisiert", [self.hans])
     self.text2 = create_textNode("Karls Text", "Ich werde nicht anonymisiert", [self.karl])
     self.text3 = create_textNode("Gemeinsamer Text", "Anonymous wird dabei geholfen haben diesen Text zu erstellen",
                                  [self.hans, self.karl])
     self.text4 = create_textNode("Gemeinsamer Text mit anonymous",
                                  "Anonymous wird dabei geholfen haben diesen Text zu erstellen",
                                  [self.hans, self.karl, self.anon])
Esempio n. 23
0
    def test_change_microblogging_authorship_can_deal_with_duplications(self):
        hugo = create_user('hugo')
        herbert = create_user('herbert')

        post = create_post('hallo @hugo ich bins @herbert!', hugo)
        post.save()
        self.assertEqual(post.text_template, 'hallo {u0} ich bins {u1}!')
        change_microblogging_authorship(hugo, herbert)
        post = Post.objects.get(id=post.id)  # update object from DB

        self.assertNotIn(hugo, post.mentions.all())
        self.assertIn(herbert, post.mentions.all())

        self.assertEqual(post.text_template, 'hallo {u0} ich bins {u0}!')
Esempio n. 24
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     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='n')
     self.leaf = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
     self.slot.append_child(self.leaf)
     self.mid.add_derivate(self.leaf, arg_type='n')
Esempio n. 25
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.permela = create_user("Permela", password="******")
     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='n')
     self.leaf = create_textNode("Bla leaf 1", "Blubb3", [self.hugo])
     self.slot.append_child(self.leaf)
     self.mid.add_derivate(self.leaf, arg_type='n')
Esempio n. 26
0
    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.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.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = [
            'Wahlprogramm', 'Grundsatzprogramm', 'Organisatorisches'
        ]
        self.full_titles = [
            'LangerWahlprogrammTitel', 'LangerGrundsatzTitel', 'Langweilig3'
        ]
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Esempio n. 27
0
def create_some_microblogging(path=None):
    if User.objects.filter(username="******").count() > 0:
        blogger1 = User.objects.filter(username="******").all()[0]
    else:
        blogger1 = create_user("Blogger 1")
    create_post(
        "Meine Oma fährt im Hühnerstall Motorrad!" if not path else "Meine Oma erwähnt /" + path + " im Hühnerstall.",
        blogger1,
    )
    if User.objects.filter(username="******").count() > 0:
        troll = User.objects.filter(username="******").all()[0]
    else:
        troll = create_user("Troll")
    if path:
        create_post("Ich erwähne /" + path + " um zu trollen. Lies das was ich schreibe und ärgere dich!", troll)
Esempio n. 28
0
 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)
Esempio n. 29
0
 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])
 def test_recovery_resolve(self):
     hans = create_user('hans', password="******")
     act = PasswordRecovery.create(hans)
     pw = act.resolve()
     self.assertTrue(pw)
     self.assertIsNone(authenticate(username='******', password='******'))
     self.assertEqual(authenticate(username='******', password=pw), hans)
Esempio n. 31
0
    def setUp(self):
        self.hugo = create_user('hugo')
        self.herbert = create_user('herbert')

        self.foo1 = create_nodes_for_path('foo.1')
        self.foo1bar1 = create_nodes_for_path('foo.1/bar.1')

        self.schema_skeleton = {
            'author': self.hugo.id,
            'location': self.foo1.id,
            'type': "userpost",
            'template_text': "some text",
            'mentions': [],
            'references': [],
            'answer_to': None
        }
Esempio n. 32
0
 def test_delete_posts_referring_to_removes_referring_posts1(self):
     hugo = create_user('hugo')
     node = create_nodes_for_path("path.1")
     create_post("foo", hugo, '/path.1')
     self.assertEqual(Post.objects.count(), 1)
     delete_posts_referring_to(node)
     self.assertEqual(Post.objects.count(), 0)
Esempio n. 33
0
    def test_load_microblogging_all_loads_all_microblogging(self):
        hugo = create_user("hugo")
        herbert = create_user("herbert")
        create_nodes_for_path("foo.1")
        posts = [
            create_post("text", hugo, location=''),
            create_post("text3", hugo, location='foo.1'),
            create_post("text2", herbert, location='foo.1')
        ]
        response = self.client.get(reverse('load_microblogging_all'))
        res = json.loads(response.content)["loadMicrobloggingResponse"]

        ids = [m["microblogID"] for m in res]
        for p in posts:
            self.assertIn(p.id, ids)
        self.assertEqual(len(res), 3)
Esempio n. 34
0
 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)
Esempio n. 35
0
def create_initial_data():
    root = get_root_node()
    decided = create_user("Beschluss_Programm",
                          description="Diese Vorschläge wurden in ihrer urspünglichen "
                                      "Fassung schon von einem Parteitag beschlossen. "
                                      "Weiterentwicklungen dieser Vorschläge sind "
                                      "natürlich kein beschlossenes Programm.",
                          groups=['texters', 'voters', 'bloggers'])

    with open(project_path("initial_data/root.txt"), 'r') as f:
        lines = f.readlines()
        for l in lines:
            if comment_line_pattern.match(l):
                continue

            slot_name, src_file = l.split()
            assert re.match('^' + SHORT_TITLE + '$', slot_name), \
                "Invalid short title '%s'." % slot_name

            src_path = project_path(os.path.join('initial_data', src_file))
            assert os.path.exists(src_path), \
                "Source file not found: '%s'." % src_path

            print("Creating '%s' from file '%s'." % (slot_name, src_path))
            slot = create_slot(slot_name)
            root.append_child(slot)
            with open(src_path, 'r') as src:
                schema = parse(unicode(src.read(), encoding='utf-8'), slot.title)
                create_structure_from_structure_node_schema(schema, slot, decided)
Esempio n. 36
0
    def setUp(self):
        self.user_max = create_user("max",password="******")
        self.user_maria = create_user("Maria")

        root = backend.get_root_node()
        slot1 = create_slot("Bla")
        root.append_child(slot1)

        self.text_node1 = create_textNode("Whatever","Testtext",[self.user_max])
        slot1.append_child(self.text_node1)

        slot2 = create_slot("Blubb")
        root.append_child(slot2)

        text_node2 = create_textNode("Whatever2","Testtext Nummer 2",[self.user_max])
        slot2.append_child(text_node2)
Esempio n. 37
0
    def test_store_microblogging(self):
        hugo = create_user('hugo', password='******')
        foo1 = create_nodes_for_path('foo.1')
        self.assertTrue(self.client.login(username="******", password="******"))
        response = self.client.post(
            reverse('store_microblogging', kwargs={'path': 'foo.1'}),
            json.dumps({
                'microblogText':
                'test stuff on http://testserver/foo.1/ and reference /foo.1 and also @hugo'
            }),
            content_type="application/json")
        res = json.loads(response.content)
        self.assertIn("storeMicrobloggingResponse", res)

        self.assertEqual(hugo.microblogging_posts.count(), 1)
        p = hugo.microblogging_posts.all()[0]
        self.assertEqual(p.location, foo1)
        self.assertEqual(p.author, hugo)
        self.assertEqual(p.post_type, Post.USER_POST)
        self.assertIn(hugo, p.mentions.all())
        self.assertIn(foo1, p.node_references.all())
        self.assertEqual(
            p.text_template,
            "test stuff on {n0}/ and reference {n0} and also {u0}")
        self.assertTrue(p.text_cache != "")
Esempio n. 38
0
 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])
Esempio n. 39
0
 def test_recovery_resolve(self):
     hans = create_user('hans', password="******")
     act = PasswordRecovery.create(hans)
     pw = act.resolve()
     self.assertTrue(pw)
     self.assertIsNone(authenticate(username='******', password='******'))
     self.assertEqual(authenticate(username='******', password=pw), hans)
Esempio n. 40
0
    def setUp(self):
        self.hugo = create_user('hugo')
        self.herbert = create_user('herbert')

        self.foo1 = create_nodes_for_path('foo.1')
        self.foo1bar1 = create_nodes_for_path('foo.1/bar.1')

        self.schema_skeleton = {
            'author': self.hugo.id,
            'location': self.foo1.id,
            'type': "userpost",
            'template_text': "some text",
            'mentions': [],
            'references': [],
            'answer_to': None
        }
Esempio n. 41
0
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])
Esempio n. 42
0
    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.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.child_slots = [self.slot11, self.slot12, self.slot13]
        self.short_titles = ['Wahlprogramm', 'Grundsatzprogramm',
                             'Organisatorisches']
        self.full_titles = ['LangerWahlprogrammTitel', 'LangerGrundsatzTitel',
                            'Langweilig3']
        self.authors = [[self.hans], [self.hugo], [self.hans, self.hugo]]
Esempio n. 43
0
 def setUp(self):
     self.root = get_root_node()
     self.mustermann = create_user("Mustermann")
     self.slot = create_slot("Flopp")
     self.root.append_child(self.slot)
     self.text1 = create_textNode("Initial Text", "Dumdidum",
                                  [self.mustermann])
     self.slot.append_child(self.text1)
Esempio n. 44
0
 def setUp(self):
     self.hugo = create_user('hugo')
     self.hans = create_user('hans')
     # create nodes
     self.root = get_root_node()
     self.foo = create_slot('foo')
     self.foo1 = create_structureNode('FooooBar')
     # add arguments
     self.foo_pro = create_argument(type='pro', title="geil", authors=[self.hugo])
     self.foo1.append_argument(self.foo_pro)
     self.foo_neut = create_argument(type='neut', title="ist", authors=[self.hans])
     self.foo1.append_argument(self.foo_neut)
     self.foo_con = create_argument(type='con', title="geiz", authors=[self.hugo, self.hans])
     self.foo1.append_argument(self.foo_con)
     # summary variables
     self.foo_arguments = [self.foo_pro, self.foo_neut, self.foo_con]
     self.arg_titles = ['geil', 'ist', 'geiz']
     self.arg_authors = [[self.hugo], [self.hans], [self.hugo, self.hans]]
Esempio n. 45
0
 def test_send_notification_to_sends_mail_via_bcc(self):
     hugo = create_user("hugo")
     post = create_post('my test posttext', hugo)
     send_notification_to('Mail für hugo!', post, ['*****@*****.**', '*****@*****.**'])
     self.assertEqual(len(mail.outbox), 1)
     m = mail.outbox[0]
     self.assertEqual(m.to, [])
     self.assertEqual(m.bcc, ['*****@*****.**', '*****@*****.**'])
     self.assertIn('my test posttext', m.body)
     self.assertIn('hugo', m.subject)
Esempio n. 46
0
 def test_microblogging_response_limited_to_newer_sorted(self):
     hugo = create_user("hugo")
     for i in range(25):
         create_post("text%d" % i, hugo)
     response = microblogging_response(Q(), {"type": "newer", "id": 3})
     self.assertTrue(validate_response(response.content,
                                       "load_microblogging"))
     result = json.loads(response.content)["loadMicrobloggingResponse"]
     self.assertEqual(len(result), 20)
     self.assertEqual([p['microblogID'] for p in result], range(23, 3, -1))
Esempio n. 47
0
 def test_mail_notify_send_derivate(self):
     hugo = create_user("hugo")
     post = create_post('my test posttext', hugo)
     send_derivate_notification(post, ['*****@*****.**', '*****@*****.**'])
     self.assertEqual(len(mail.outbox), 1)
     m = mail.outbox[0]
     self.assertEqual(m.to, [])
     self.assertEqual(m.bcc, ['*****@*****.**', '*****@*****.**'])
     self.assertIn('my test posttext', m.body)
     self.assertGreater(len(m.subject), 0)
Esempio n. 48
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.slot = create_slot("Slot")
     self.root.append_child(self.slot)
     self.text = create_textNode("Bla",
         "Dieser Text enthält verschiedene Suchbegriffe wie Giraffe, Huhn, Motorrad und Tisch.", [self.hugo])
     self.slot.append_child(self.text)
     self.post1 = create_post("Ich finde /Slot.1 Huhn.", self.hugo)
     self.post1 = create_post("Giraffe Huhn.", self.hugo)
Esempio n. 49
0
 def test_post_node_was_flagged_message(self):
     hugo = create_user('Hugo')
     post = post_node_was_flagged_message('/', hugo)
     self.assertEqual(post.author, get_system_user())
     self.assertEqual(post.location, get_root_node())
     self.assertEqual(post.post_type, Post.SPAM_MARKED)
     self.assertIn(hugo, post.mentions.all())
     self.assertEqual(
         post.text_cache, '<span style="color: gray;">Hinweis:</span> ' +
         '<a href="/user/Hugo">@Hugo</a> hat <a href="/">ROOT'
         '<span class="nodeIndex">1</span></a> als Spam markiert.')
Esempio n. 50
0
 def setUp(self):
     self.hugo = create_user('hugo')
     self.hans = create_user('hans')
     # create nodes
     self.root = get_root_node()
     self.foo = create_slot('foo')
     self.root.append_child(self.foo)
     self.foo1 = create_structureNode('FooooBar')
     self.foo.append_child(self.foo1)
     # add arguments
     self.foo_pro = create_argument(self.foo1, arg_type='pro', title="geil",
                                    authors=[self.hugo])
     self.foo_neut = create_argument(self.foo1, arg_type='neut',
                                     title="ist", authors=[self.hans])
     self.foo_con = create_argument(self.foo1, arg_type='con', title="geiz",
                                    authors=[self.hugo, self.hans])
     # summary variables
     self.foo_arguments = [self.foo_pro, self.foo_neut, self.foo_con]
     self.arg_titles = ['geil', 'ist', 'geiz']
     self.arg_authors = [[self.hugo], [self.hans], [self.hugo, self.hans]]
Esempio n. 51
0
 def setUp(self):
     self.hans = create_user('hans', description='noneSoFar',
                             password="******")
     self.karl = create_user('karl', description='none',
                             password="******")
     self.anon = User.objects.filter(username='******').all()[0]
     self.slot = create_slot("test")
     self.text1 = create_textNode("Hans Text", "Ich werde anonymisiert",
                                  [self.hans])
     self.text2 = create_textNode("Karls Text",
                                  "Ich werde nicht anonymisiert",
                                  [self.karl])
     self.text3 = create_textNode("Gemeinsamer Text",
                                  "Anonymous wird dabei geholfen haben "
                                  "diesen Text zu erstellen",
                                  [self.hans, self.karl])
     self.text4 = create_textNode("Gemeinsamer Text mit anonymous",
                                  "Anonymous wird dabei geholfen haben "
                                  "diesen Text zu erstellen",
                                  [self.hans, self.karl, self.anon])
Esempio n. 52
0
 def setUp(self):
     self.root = get_root_node()
     self.hugo = create_user("Hugo", password="******", groups=['voters'])
     self.slot = create_slot("Slot")
     self.root.append_child(self.slot)
     self.text = create_textNode(
         "Bla",
         "Dieser Text enthält verschiedene Suchbegriffe wie Giraffe, Huhn, Motorrad und Tisch.",
         [self.hugo])
     self.slot.append_child(self.text)
     self.post1 = create_post("Ich finde /Slot.1 Huhn.", self.hugo)
     self.post1 = create_post("Giraffe Huhn.", self.hugo)
Esempio n. 53
0
    def test_load_microblogging_timeline(self):
        hugo = create_user("hugo")
        herbert = create_user("herbert")
        heinrich = create_user("heinrich")

        herbert.profile.followers.add(hugo.profile)

        posts = [
            create_post("Own Post", hugo, location=''),
            create_post("Followed Post", herbert, location='')
        ]
        wrong_post = create_post("Wrong Post", heinrich, location='')

        response = self.client.get(
            reverse('load_microblogging_timeline', 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)
        self.assertNotIn(wrong_post.id, response_id_list)
        self.assertEqual(len(res), 2)