コード例 #1
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_ahfooT5leilahcohJ2uz',
                          text='test_text_enoogh7OhPoo6eohoCus')
     self.motion.save()
     self.state_id_accepted = 2  # This should be the id of the state 'accepted'.
コード例 #2
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_iac4ohquie9Ku6othieC',
                          text='test_text_Xohphei6Oobee0Evooyu')
     self.motion.save()
     self.state_id_accepted = 2  # This should be the id of the state 'accepted'.
コード例 #3
0
 def setUp(self):
     self.admin = get_user_model().objects.get(username='******')
     self.admin.groups.add(2)
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_chee7ahCha6bingaew4e',
                          text='test_text_birah1theL9ooseeFaip')
     self.motion.save()
コード例 #4
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_uj5eeSiedohSh3ohyaaj',
                          text='test_text_ithohchaeThohmae5aug')
     self.motion.save()
     self.motion.create_poll()
コード例 #5
0
 def test_numbering_with_given_order(self):
     self.motion_3 = Motion(title='test_title_eeb0kua5ciike4su2auJ',
                            text='test_text_ahshuGhaew3eim8yoht7',
                            category=self.category)
     self.motion_3.save()
     self.motion_3.identifier = ''
     self.motion_3.save()
     response = self.client.post(reverse('category-numbering',
                                         args=[self.category.pk]),
                                 {'motions': [3, 2]},
                                 format='json')
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(
         response.data, {
             'detail':
             'All motions in category test_cateogory_name_zah6Ahd4Ifofaeree6ai numbered successfully.'
         })
     self.assertEqual(
         Motion.objects.get(pk=self.motion.pk).identifier, None)
     self.assertEqual(
         Motion.objects.get(pk=self.motion_2.pk).identifier,
         'test_prefix_ahz6tho2mooH8 2')
     self.assertEqual(
         Motion.objects.get(pk=self.motion_3.pk).identifier,
         'test_prefix_ahz6tho2mooH8 1')
コード例 #6
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_Aiqueigh2dae9phabiqu',
                          text='test_text_Neekoh3zou6li5rue8iL')
     self.motion.save()
     self.poll = self.motion.create_poll()
コード例 #7
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username="******", password="******")
     self.motion = Motion(
         title="test_title_aeng7ahChie3waiR8xoh",
         text="test_text_xeigheeha7thopubeu4U",
     )
     self.motion.save()
コード例 #8
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.category = Category.objects.create(
         name='test_cateogory_name_zah6Ahd4Ifofaeree6ai',
         prefix='test_prefix_ahz6tho2mooH8')
     self.motion = Motion(title='test_title_Eeha8Haf6peulu8ooc0z',
                          text='test_text_faghaZoov9ooV4Acaquk',
                          category=self.category)
     self.motion.save()
     self.motion.identifier = ''
     self.motion.save()
     self.motion_2 = Motion(title='test_title_kuheih2eja2Saeshusha',
                            text='test_text_Ha5ShaeraeSuthooP2Bu',
                            category=self.category)
     self.motion_2.save()
     self.motion_2.identifier = ''
     self.motion_2.save()
コード例 #9
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_InieJ5HieZieg1Meid7K',
                          text='test_text_daePhougho7EenguWe4g')
     self.motion.save()
     self.version_2 = self.motion.get_new_version(
         title='new_title_fee7tef0seechazeefiW')
     self.motion.save(use_version=self.version_2)
コード例 #10
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username="******", password="******")
     self.admin = get_user_model().objects.get(username="******")
     self.motion = Motion(
         title="test_title_acle3fa93l11lwlkcc31",
         text="test_text_f390sjfyycj29ss56sro",
     )
     self.motion.save()
コード例 #11
0
    def test_set_identifier_allready_set(self):
        """
        If the motion already has a identifier, the method does nothing.
        """
        motion = Motion(identifier='My test identifier')

        motion.set_identifier()

        self.assertEqual(motion.identifier, 'My test identifier')
コード例 #12
0
 def setUp(self):
     self.client = APIClient()
     self.client.login(username='******', password='******')
     self.motion = Motion(title='test_title_uj5eeSiedohSh3ohyaaj',
                          text='test_text_ithohchaeThohmae5aug')
     self.motion.save()
     self.motion.create_poll()
     for index in range(10):
         get_user_model().objects.create_user(
             username='******'.format(index), password='******')
コード例 #13
0
 def setUp(self):
     self.admin = get_user_model().objects.get(username="******")
     self.admin.groups.add(GROUP_DELEGATE_PK)
     inform_changed_data(self.admin)
     self.client.login(username="******", password="******")
     self.motion = Motion(
         title="test_title_chee7ahCha6bingaew4e",
         text="test_text_birah1theL9ooseeFaip",
     )
     self.motion.save()
コード例 #14
0
ファイル: test_models.py プロジェクト: MiGo42/Openslides3_git
 def setUp(self):
     self.motion = Motion(
         title="test_title_OoK9IeChe2Jeib9Deeji",
         text="test_text_eichui1oobiSeit9aifo",
     )
     self.poll = MotionPoll(
         motion=self.motion,
         title="test_title_tho8PhiePh8upaex6phi",
         pollmethod="YNA",
         type=MotionPoll.TYPE_NAMED,
     )
コード例 #15
0
    def test_set_identifier_manually(self):
        """
        If the config is set to manually, the method does nothing.
        """
        config['motions_identifier'] = 'manually'
        motion = Motion()

        motion.set_identifier()

        # If the identifier should be set manually, the method does nothing
        self.assertIsNone(motion.identifier)
コード例 #16
0
ファイル: test_motions.py プロジェクト: topelrapha/OpenSlides
 def setUp(self):
     self.client = APIClient()
     self.client.login(username="******", password="******")
     self.motion = Motion(
         title="test_title_uj5eeSiedohSh3ohyaaj",
         text="test_text_ithohchaeThohmae5aug",
     )
     self.motion.save()
     for index in range(10):
         get_user_model().objects.create_user(username=f"user_{index}",
                                              password="******")
コード例 #17
0
ファイル: test_viewset.py プロジェクト: topelrapha/OpenSlides
 def test_existing_identifier_no_category(self):
     # config["motions_identifier_with_blank"] = True
     conflicting_motion = Motion(
         title="test_title_al2=2k21fjv1lsck3ehlWExg",
         text="test_text_3omvpEhnfg082ejplk1m",
     )
     conflicting_motion.save()
     conflicting_motion.identifier = "test_C3-2-1"
     conflicting_motion.save()
     response = self.client.post(reverse("category-numbering", args=[self.A.pk]))
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertEqual("test_C3-2-1", response.data["args"][0])
コード例 #18
0
ファイル: test_viewset.py プロジェクト: funakura/OpenSlides
    def test_delete_with_assigned_motions(self):
        self.motion = Motion(
            title="test_title_chee7ahCha6bingaew4e",
            text="test_text_birah1theL9ooseeFaip",
        )
        self.motion.reset_state(self.workflow)
        self.motion.save()

        response = self.client.delete(
            reverse("workflow-detail", args=[self.workflow.pk]))
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(Workflow.objects.count(), 2)
コード例 #19
0
    def test_set_identifier_amendment(self):
        """
        If the motion is an amendment, the identifier is the identifier from the
        parent + a suffix.
        """
        config['motions_amendments_enabled'] = True
        self.motion.identifier = 'Parent identifier'
        self.motion.save()
        motion = Motion(parent=self.motion)

        motion.set_identifier()

        self.assertEqual(motion.identifier, 'Parent identifier A 1')
コード例 #20
0
ファイル: test_models.py プロジェクト: topelrapha/OpenSlides
    def test_set_identifier_amendment(self):
        """
        If the motion is an amendment, the identifier is the identifier from the
        parent + a suffix.
        """
        config["motions_amendments_enabled"] = True
        config["motions_identifier_with_blank"] = False
        self.motion.identifier = "Parent identifier"
        self.motion.save()
        motion = Motion(parent=self.motion)

        motion.set_identifier()

        self.assertEqual(motion.identifier, "Parent identifier-1")
コード例 #21
0
    def test_version_data(self):
        motion = Motion()
        self.assertEqual(motion.title, '')
        with self.assertRaises(AttributeError):
            self._title

        motion.title = 'title'
        self.assertEqual(motion._title, 'title')

        motion.text = 'text'
        self.assertEqual(motion._text, 'text')

        motion.reason = 'reason'
        self.assertEqual(motion._reason, 'reason')
コード例 #22
0
    def test_set_identifier_second_amendment(self):
        """
        If a motion has already an amendment, the second motion gets another
        identifier.
        """
        config['motions_amendments_enabled'] = True
        self.motion.identifier = 'Parent identifier'
        self.motion.save()
        Motion.objects.create(title='Amendment1', parent=self.motion)
        motion = Motion(parent=self.motion)

        motion.set_identifier()

        self.assertEqual(motion.identifier, 'Parent identifier A 2')
コード例 #23
0
    def test_set_identifier_second_amendment(self):
        """
        If a motion has already an amendment, the second motion gets another
        identifier.
        """
        config["motions_amendments_enabled"] = True
        self.motion.identifier = "Parent identifier"
        self.motion.save()
        Motion.objects.create(title="Amendment1", parent=self.motion)
        motion = Motion(parent=self.motion)

        motion.set_identifier()

        self.assertEqual(motion.identifier, "Parent identifier - 2")
コード例 #24
0
    def setUp(self):
        self.state_id_accepted = 2  # This should be the id of the state 'accepted'.
        self.state_id_rejected = 3  # This should be the id of the state 'rejected'.

        self.client = APIClient()
        self.client.login(username='******', password='******')

        self.motion_block = MotionBlock.objects.create(
            title='test_motion_block_name_Ufoopiub7quaezaepeic')

        self.motion = Motion(title='test_title_yo8ohy5eifeiyied2AeD',
                             text='test_text_chi1aeth5faPhueQu8oh',
                             motion_block=self.motion_block)
        self.motion.save()
        self.motion.set_recommendation(self.state_id_accepted)
        self.motion.save()

        self.motion_2 = Motion(title='test_title_eith0EemaW8ahZa9Piej',
                               text='test_text_haeho1ohk3ou7pau2Jee',
                               motion_block=self.motion_block)
        self.motion_2.save()
        self.motion_2.set_recommendation(self.state_id_rejected)
        self.motion_2.save()
コード例 #25
0
ファイル: test_viewset.py プロジェクト: funakura/OpenSlides
 def test_existing_identifier_with_category(self):
     conflicting_category = Category.objects.create(
         name="test_name_hpsodhakvjdbvkblwfjr")
     conflicting_motion = Motion(
         title="test_title_al2=2k21fjv1lsck3ehlWExg",
         text="test_text_3omvpEhnfg082ejplk1m",
         category=conflicting_category,
     )
     conflicting_motion.save()
     conflicting_motion.identifier = "test_C3-2-1"
     conflicting_motion.save()
     response = self.client.post(
         reverse("category-numbering", args=[self.A.pk]))
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertEqual("test_C3-2-1", response.data["args"][0])
     self.assertEqual(conflicting_category.name, response.data["args"][1])
コード例 #26
0
 def create_motions(self, options):
     number_of_motions = options["motions"]
     if number_of_motions is None and not options["only"]:
         number_of_motions = DEFAULT_NUMBER
     if number_of_motions is not None and number_of_motions > 0:
         self.stdout.write(f"Start creating {number_of_motions} motions ...")
         text = ""
         for i in range(MOTION_NUMBER_OF_PARAGRAPHS):
             text += dedent(LOREM_IPSUM[i % 3])
         for i in range(number_of_motions):
             motion = Motion(title=get_random_string(20, self.chars), text=text)
             motion.save(skip_autoupdate=True)
         self.stdout.write(
             self.style.SUCCESS(f"{number_of_motions} motions successfully created.")
         )
     elif number_of_motions is not None and number_of_motions < 0:
         raise CommandError("Number for motions must not be negative.")
コード例 #27
0
ファイル: test_viewset.py プロジェクト: topelrapha/OpenSlides
    def setUp(self):
        self.client = APIClient()
        self.client.login(username="******", password="******")

        motion = Motion(
            title="test_title_3kd)K23,c9239mdj2wcG",
            text="test_text_f8FLP,gvprC;wovVEwlQ",
        )
        motion.save()

        self.public_cr = MotionChangeRecommendation(
            motion=motion, internal=False, line_from=1, line_to=1
        )
        self.public_cr.save()

        self.internal_cr = MotionChangeRecommendation(
            motion=motion, internal=True, line_from=2, line_to=2
        )
        self.internal_cr.save()
コード例 #28
0
ファイル: test_models.py プロジェクト: MiGo42/Openslides3_git
    def test_overlapping_line_numbers(self):
        """
        Tests that a change recommendation directly before another one can be created
        """
        motion = Motion()
        existing_recommendation = MotionChangeRecommendation()
        existing_recommendation.line_from = 5
        existing_recommendation.line_to = 7
        existing_recommendation.rejected = False
        existing_recommendation.motion = motion
        other_recommendations = [existing_recommendation]

        new_recommendation1 = MotionChangeRecommendation()
        new_recommendation1.line_from = 3
        new_recommendation1.line_to = 5
        collides = new_recommendation1.collides_with_other_recommendation(
            other_recommendations
        )
        self.assertFalse(collides)

        new_recommendation2 = MotionChangeRecommendation()
        new_recommendation2.line_from = 3
        new_recommendation2.line_to = 6
        collides = new_recommendation2.collides_with_other_recommendation(
            other_recommendations
        )
        self.assertTrue(collides)

        new_recommendation3 = MotionChangeRecommendation()
        new_recommendation3.line_from = 6
        new_recommendation3.line_to = 8
        collides = new_recommendation3.collides_with_other_recommendation(
            other_recommendations
        )
        self.assertTrue(collides)

        new_recommendation4 = MotionChangeRecommendation()
        new_recommendation4.line_from = 7
        new_recommendation4.line_to = 9
        collides = new_recommendation4.collides_with_other_recommendation(
            other_recommendations
        )
        self.assertFalse(collides)
コード例 #29
0
    def test_do_not_create_new_version_when_permit_old_version(self):
        motion = Motion()
        motion.title = 'foo'
        motion.text = 'bar'
        motion.save()
        first_version = motion.get_last_version()

        motion = Motion.objects.get(pk=motion.pk)
        motion.title = 'New Title'
        motion.save(use_version=motion.get_new_version())
        new_version = motion.get_last_version()
        self.assertEqual(motion.versions.count(), 2)

        motion.active_version = new_version
        motion.save()
        self.assertEqual(motion.versions.count(), 2)

        motion.active_version = first_version
        motion.save(use_version=False)
        self.assertEqual(motion.versions.count(), 2)
コード例 #30
0
ファイル: test_viewset.py プロジェクト: topelrapha/OpenSlides
    def setUp(self):
        self.client = APIClient()
        self.client.login(username="******", password="******")

        self.admin = get_user_model().objects.get()
        self.group_out = get_group_model().objects.get(
            pk=GROUP_DELEGATE_PK
        )  # The admin should not be in this group

        # Put the admin into the staff group, becaust in the admin group, he has all permissions for
        # every single comment section.
        self.admin.groups.add(GROUP_STAFF_PK)
        self.admin.groups.remove(GROUP_ADMIN_PK)
        inform_changed_data(self.admin)
        self.group_in = get_group_model().objects.get(pk=GROUP_STAFF_PK)

        self.motion = Motion(
            title="test_title_SlqfMw(waso0saWMPqcZ",
            text="test_text_f30skclqS9wWF=xdfaSL",
        )
        self.motion.save()

        self.section_no_groups = MotionCommentSection(
            name='test_name_gj4F§(fj"(edm"§F3f3fs'
        )
        self.section_no_groups.save()

        self.section_read = MotionCommentSection(name="test_name_2wv30(d2S&kvelkakl39")
        self.section_read.save()
        self.section_read.read_groups.add(
            self.group_in, self.group_out
        )  # Group out for testing multiple groups
        self.section_read.write_groups.add(self.group_out)

        self.section_read_write = MotionCommentSection(
            name="test_name_a3m9sd0(Mw2%slkrv30,"
        )
        self.section_read_write.save()
        self.section_read_write.read_groups.add(self.group_in)
        self.section_read_write.write_groups.add(self.group_in)