Esempio n. 1
0
    def test_listing_page_of_protocols_with_over_30_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        for add_protocol in range(35):
            client.post(
                '/protocols/add/', {
                    "topics-TOTAL_FORMS": 2,
                    "topics-INITIAL_FORMS": 0,
                    "topics-MAX_NUM_FORMS": 1000,
                    "institution": self.institution.pk,
                    "number": "{}".format(add_protocol),
                    "start_time": time(10, 0, 0),
                    "scheduled_time": time(9, 0, 0),
                    "quorum": 32,
                    "excused": self.kril.pk,
                    "absent": self.kril.pk,
                    "attendents": self.kril.pk,
                    "majority": 5,
                    "current_majority": 4,
                    "voted_for": 2,
                    "voted_against": 3,
                    "voted_abstain": 0,
                    "information": 'this is the best protocol ever',
                })

        response_1 = client.get('/protocols/archive/1/')
        response_2 = client.get('/protocols/archive/2/')

        after_add = Protocol.objects.count()
        self.assertEqual(200, response_1.status_code)
        self.assertEqual(200, response_2.status_code)
        self.assertEqual(before_add + 35, after_add)
        self.assertEqual(30, len(response_1.context['protocols']))
        self.assertEqual(5, len(response_2.context['protocols']))
Esempio n. 2
0
    def test_user_reports_count_2(self):
        before_add = Report.objects.count()
        copies_before_add = Copy.objects.count()
        client.login(username='******', password='******')
        response = client.post('/reports/add/', {
            "copies-TOTAL_FORMS": 2,
            "copies-INITIAL_FORMS": 0,
            "copies-MAX_NUM_FORMS": 1000,
            "addressed_to": "Hackfmi",
            "reported_from": self.kril.pk,
            "content": "This is a report test",
            "copies-0-about_topic": self.topic1.pk,
            "copies-1-about_topic": self.topic2.pk,
            "signed_from": "rozovo zaiche", })

        self.assertEqual(200, response.status_code)

        response = client.post('/reports/add/', {
            "copies-TOTAL_FORMS": 2,
            "copies-INITIAL_FORMS": 0,
            "copies-MAX_NUM_FORMS": 1000,
            "addressed_to": "Hackfmi",
            "reported_from": self.kril.pk,
            "content": "This is a report test",
            "signed_from": "rozovo zaiche", })
        after_add = Report.objects.count()
        copies_after_add = Copy.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, after_add)
        self.assertEqual(copies_before_add + 2, copies_after_add)
Esempio n. 3
0
    def test_display_protocols_by_date(self):
        client.login(username='******', password='******')
        client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever',
            })

        start_date = str(date.today() - timedelta(days=3))
        end_date = str(date.today() + timedelta(days=3))

        response = client.get('/protocols/search/{}/{}/'.format(
            start_date, end_date))

        self.assertEqual(200, response.status_code)
        self.assertEqual(1, len(response.context['protocols']))
Esempio n. 4
0
    def test_edit_project_impossible_from_this_user(self):
        '''this user is not the creator of the project'''

        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='some other name').count()

        project = Project.objects.create(
            user=self.user,
            flp=self.user,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        data_copy = self.test_data.copy()
        data_copy.update({'name': 'some other name'})

        response = client.post('/projects/edit/{}/'.format(project.pk), data_copy)

        after_edit = Project.objects.filter(name='some other name').count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_edit, after_edit)
Esempio n. 5
0
    def test_listing_page_of_reports(self):
        before_add = Report.objects.count()
        copies_before_add = Copy.objects.count()
        client.login(username='******', password='******')
        for report in range(10):
            response = client.post('/reports/add/', {
                "copies-TOTAL_FORMS": 2,
                "copies-INITIAL_FORMS": 0,
                "copies-MAX_NUM_FORMS": 1000,
                "addressed_to": "Hackfmi",
                "reported_from": self.kril.pk,
                "content": "This is a report test",
                "copies-0-about_topic": self.topic1.pk,
                "copies-1-about_topic": self.topic2.pk,
                "copies-2-about_topic": self.topic3.pk,
                "signed_from": "rozovo zaiche", })

        response = client.get('/reports/archive/1/')

        after_add = Report.objects.all().count()
        copies_after_add = Copy.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 10, after_add)
        self.assertEqual(copies_before_add + 20, copies_after_add)
        self.assertEqual(after_add, len(response.context['reports']))
Esempio n. 6
0
    def test_complex_search(self):
        client.login(username='******', password='******')

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='Old project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        search_data = urlencode({"name": "New project", "status": "unrevised", "flp": self.not_master.first_name})

        response = client.get('/projects/archive/?{}'.format(search_data))
        projects = Project.objects.filter(name="New project")

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Esempio n. 7
0
    def test_edit_project_impossible_from_this_user(self):
        '''this user is not the creator of the project'''

        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='some other name').count()

        project = Project.objects.create(user=self.user,
                                         flp=self.user,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        data_copy = self.test_data.copy()
        data_copy.update({'name': 'some other name'})

        response = client.post('/projects/edit/{}/'.format(project.pk),
                               data_copy)

        after_edit = Project.objects.filter(name='some other name').count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_edit, after_edit)
Esempio n. 8
0
    def test_listing_page_of_reports(self):
        before_add = Report.objects.count()
        copies_before_add = Copy.objects.count()
        client.login(username='******', password='******')
        for report in range(10):
            response = client.post(
                '/reports/add/', {
                    "copies-TOTAL_FORMS": 2,
                    "copies-INITIAL_FORMS": 0,
                    "copies-MAX_NUM_FORMS": 1000,
                    "addressed_to": "Hackfmi",
                    "reported_from": self.kril.pk,
                    "content": "This is a report test",
                    "copies-0-about_topic": self.topic1.pk,
                    "copies-1-about_topic": self.topic2.pk,
                    "copies-2-about_topic": self.topic3.pk,
                    "signed_from": "rozovo zaiche",
                })

        response = client.get('/reports/archive/1/')

        after_add = Report.objects.all().count()
        copies_after_add = Copy.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 10, after_add)
        self.assertEqual(copies_before_add + 20, copies_after_add)
        self.assertEqual(after_add, len(response.context['reports']))
Esempio n. 9
0
    def test_user_reports_count_2(self):
        before_add = Report.objects.count()
        copies_before_add = Copy.objects.count()
        client.login(username='******', password='******')
        response = client.post(
            '/reports/add/', {
                "copies-TOTAL_FORMS": 2,
                "copies-INITIAL_FORMS": 0,
                "copies-MAX_NUM_FORMS": 1000,
                "addressed_to": "Hackfmi",
                "reported_from": self.kril.pk,
                "content": "This is a report test",
                "copies-0-about_topic": self.topic1.pk,
                "copies-1-about_topic": self.topic2.pk,
                "signed_from": "rozovo zaiche",
            })

        self.assertEqual(200, response.status_code)

        response = client.post(
            '/reports/add/', {
                "copies-TOTAL_FORMS": 2,
                "copies-INITIAL_FORMS": 0,
                "copies-MAX_NUM_FORMS": 1000,
                "addressed_to": "Hackfmi",
                "reported_from": self.kril.pk,
                "content": "This is a report test",
                "signed_from": "rozovo zaiche",
            })
        after_add = Report.objects.count()
        copies_after_add = Copy.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, after_add)
        self.assertEqual(copies_before_add + 2, copies_after_add)
Esempio n. 10
0
    def test_listing_page_of_protocols_with_over_30_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        for add_protocol in range(35):
            client.post('/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "{}".format(add_protocol),
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "excused": self.kril.pk,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever', })

        response_1 = client.get('/protocols/archive/1/')
        response_2 = client.get('/protocols/archive/2/')

        after_add = Protocol.objects.count()
        self.assertEqual(200, response_1.status_code)
        self.assertEqual(200, response_2.status_code)
        self.assertEqual(before_add + 35, after_add)
        self.assertEqual(30, len(response_1.context['protocols']))
        self.assertEqual(5, len(response_2.context['protocols']))
Esempio n. 11
0
    def test_update_user_information(self):
        client.login(username='******', password='******')
        before_add = Protocol.objects.count()
        response = client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "13/11/1992/1234",
            "scheduled_time": time(9, 0, 0),
            "start_time": time(10, 0, 0),
            "quorum": 32,
            "excused": self.kril.pk,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "voted_for": 2,
            "voted_against": 3,
            "voted_abstain": 0,
            "information": 'this is the best protocol ever', })
        after_add = Protocol.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Esempio n. 12
0
 def test_add_protocol_with_topic(self):
     before_add = Protocol.objects.count()
     topics_count_before = Topic.objects.count()
     client.login(username='******', password='******')
     response = client.post(
         '/protocols/add/', {
             "topics-TOTAL_FORMS": 1,
             "topics-INITIAL_FORMS": 0,
             "topics-MAX_NUM_FORMS": 1000,
             "institution": self.institution.pk,
             "number": "13/11/1992/1234",
             "start_time": time(10, 0, 0),
             "scheduled_time": time(9, 0, 0),
             "quorum": 32,
             "absent": self.kril.pk,
             "attendents": self.kril.pk,
             "majority": 5,
             "current_majority": 4,
             "information": 'this is the best protocol ever',
             "topics-0-name": "topic",
             "topics-0-voted_for": 4,
             "topics-0-voted_against": 4,
             "topics-0-voted_abstain": 4,
             "topics-0-statement": "4",
         })
Esempio n. 13
0
    def test_display_protocol_by_id(self):
        client.login(username='******', password='******')
        c_post = client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "excused": self.kril.pk,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "voted_for": 2,
            "voted_against": 3,
            "voted_abstain": 0,
            "information": 'this is the best protocol ever', })

        response = client.get('/protocols/archive/review/{}/'.format(
                                                c_post.context['protocol'].pk))

        self.assertEqual(200, response.status_code)
Esempio n. 14
0
    def test_display_protocols_by_date(self):
        client.login(username='******', password='******')
        client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "voted_for": 2,
            "voted_against": 3,
            "voted_abstain": 0,
            "information": 'this is the best protocol ever', })

        start_date = str(date.today() - timedelta(days=3))
        end_date   = str(date.today() + timedelta(days=3))

        response = client.get('/protocols/search/{}/{}/'.format(start_date, end_date))

        self.assertEqual(200, response.status_code)
        self.assertEqual(1, len(response.context['protocols']))
Esempio n. 15
0
    def test_display_protocol_by_id(self):
        client.login(username='******', password='******')
        c_post = client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "excused": self.kril.pk,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever',
            })

        response = client.get('/protocols/archive/review/{}/'.format(
            c_post.context['protocol'].pk))

        self.assertEqual(200, response.status_code)
Esempio n. 16
0
    def test_update_user_information(self):
        client.login(username='******', password='******')
        before_add = Protocol.objects.count()
        response = client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "13/11/1992/1234",
                "scheduled_time": time(9, 0, 0),
                "start_time": time(10, 0, 0),
                "quorum": 32,
                "excused": self.kril.pk,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever',
            })
        after_add = Protocol.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Esempio n. 17
0
    def test_add_member_to_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        user_id = self.kril.pk
        response = client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, user_id))
        after_add = self.institution.members.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Esempio n. 18
0
    def test_add_member_to_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        user_id = self.kril.pk
        response = client.get(
            '/protocols/institution/add_member/{}/{}/'.format(
                institution_id, user_id))
        after_add = self.institution.members.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Esempio n. 19
0
 def test_adding_incomplete_project(self):
     client.login(username='******', password='******')
     before_add = Project.objects.count()
     response = client.post('/projects/add/', {
         'team': [self.user.pk],
         'name': 'New project',
         'description': 'spam',
         'target_group': 'spam',
         'schedule': 'spam',
         'resources': 'spam',
         'finance_description': 'spam'})
     after_add = Project.objects.count()
     self.assertEqual(response.status_code, 200)
     self.assertEqual(before_add, after_add)
Esempio n. 20
0
    def test_showing_members_of_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        kril_id = self.kril.pk
        fake_id = self.fake_kril.pk
        before_add = self.institution.members.count()

        client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, kril_id))
        client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, fake_id))
        response = client.get('/protocols/institution/members/{}/'.format(institution_id))

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, response.context['members'].count())
Esempio n. 21
0
    def test_all_protocol_fields(self):
        before_add = Protocol.objects.count()
        topics_count_before = Topic.objects.count()
        client.login(username='******', password='******')
        with open(
                os.path.join(settings.PROJECT_PATH,
                             'static/img/chrome_logo.png')) as f:
            response = client.post(
                '/protocols/add/', {
                    "topics-TOTAL_FORMS": 1,
                    "topics-INITIAL_FORMS": 0,
                    "topics-MAX_NUM_FORMS": 1000,
                    "institution": self.institution.pk,
                    "number": "13/11/1992/1234",
                    "start_time": time(10, 0, 0),
                    "scheduled_time": time(9, 0, 0),
                    "quorum": 32,
                    "excused": self.kril.pk,
                    "absent": self.kril.pk,
                    "attendents": self.kril.pk,
                    "majority": 5,
                    "current_majority": 4,
                    "voted_for": 2,
                    "voted_against": 3,
                    "voted_abstain": 0,
                    "information": 'this is the best protocol ever',
                    "topics-0-name": "topic",
                    "topics-0-voted_for": 4,
                    "topics-0-voted_against": 4,
                    "topics-0-voted_abstain": 4,
                    "topics-0-statement": "4",
                    "additional": " Additional",
                    "information": "Information",
                    "files": f,
                    "topics-0-files1": f,
                    "topics-0-files2": f,
                })
        topics_count_after = Topic.objects.count()
        after_add = Protocol.objects.count()
        protocol = Protocol.objects.get(number="13/11/1992/1234")

        self.assertEqual(response.status_code, 200)
        self.assertEqual(before_add + 1, after_add)
        self.assertEqual(topics_count_before + 1, topics_count_after)
        self.assertEqual(protocol.topics.all()[0].name, "topic")
        self.assertTrue(protocol.files.exists())
        self.assertTrue(protocol.topics.all()[0].files.exists())
        self.assertEqual(protocol.topics.all()[0].files.all().count(), 2)
Esempio n. 22
0
    def test_add_report_no_copies(self):
        client.login(username='******', password='******')
        before_add = Report.objects.count()
        response = client.post('/reports/add/', {
            "copies-TOTAL_FORMS": 2,
            "copies-INITIAL_FORMS": 0,
            "copies-MAX_NUM_FORMS": 1000,
            "addressed_to": "Hackfmi",
            "reported_from": self.kril.pk,
            "content": "This is a report test",
            "signed_from": "rozovo zaiche", })

        after_add = Report.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Esempio n. 23
0
 def test_adding_incomplete_project(self):
     client.login(username='******', password='******')
     before_add = Project.objects.count()
     response = client.post(
         '/projects/add/', {
             'team': [self.user.pk],
             'name': 'New project',
             'description': 'spam',
             'target_group': 'spam',
             'schedule': 'spam',
             'resources': 'spam',
             'finance_description': 'spam'
         })
     after_add = Project.objects.count()
     self.assertEqual(response.status_code, 200)
     self.assertEqual(before_add, after_add)
Esempio n. 24
0
    def test_unauthorised_to_report_user(self):
        before_add = Report.objects.count()
        client.login(username='******', password='******')
        for report in range(10):
            response = client.post('/reports/add/', {
                "copies-TOTAL_FORMS": 2,
                "copies-INITIAL_FORMS": 0,
                "copies-MAX_NUM_FORMS": 1000,
                "addressed_to": "Hackfmi",
                "reported_from": self.kril.pk,
                "content": "This is a report test",
                "signed_from": "rozovo zaiche", })

        after_add = Report.objects.count()
        self.assertEqual(302, response.status_code)
        self.assertEqual(before_add, after_add)
Esempio n. 25
0
    def test_showing_members_of_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        kril_id = self.kril.pk
        fake_id = self.fake_kril.pk
        before_add = self.institution.members.count()

        client.get('/protocols/institution/add_member/{}/{}/'.format(
            institution_id, kril_id))
        client.get('/protocols/institution/add_member/{}/{}/'.format(
            institution_id, fake_id))
        response = client.get(
            '/protocols/institution/members/{}/'.format(institution_id))

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, response.context['members'].count())
Esempio n. 26
0
    def test_listing_page_of_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "information": 'this is the best protocol ever',
            })

        client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "13/11/1992/1235",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "information": 'this is the best protocol ever',
            })

        response = client.get('/protocols/archive/1/')

        after_add = Protocol.objects.count()
        topic = Topic.objects.filter(name="topic", statement="4").exists()
        topics_count_after = Topic.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, after_add)
        self.assertEqual(after_add, len(response.context['protocols']))
Esempio n. 27
0
    def test_add_report_no_copies(self):
        client.login(username='******', password='******')
        before_add = Report.objects.count()
        response = client.post(
            '/reports/add/', {
                "copies-TOTAL_FORMS": 2,
                "copies-INITIAL_FORMS": 0,
                "copies-MAX_NUM_FORMS": 1000,
                "addressed_to": "Hackfmi",
                "reported_from": self.kril.pk,
                "content": "This is a report test",
                "signed_from": "rozovo zaiche",
            })

        after_add = Report.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Esempio n. 28
0
 def test_edit_status_of_project_user_has_permissions(self):
     client.login(username='******', password='******')
     Project.objects.create(user=self.not_master,
                            flp=self.user,
                            name='New project',
                            description='spam',
                            tasks='spam',
                            targets='spam',
                            target_group='spam',
                            schedule='spam',
                            resources='spam',
                            finance_description='spam')
     before_add = Project.objects.count()
     response = client.post('/projects/edit_status/1/',
                            {'status': 'approved'})
     after_add = Project.objects.count()
     self.assertEqual(response.status_code, 302)
     self.assertEqual(before_add, after_add)
Esempio n. 29
0
 def test_edit_project_from_its_creator(self):
     client.login(username='******', password='******')
     Project.objects.create(user=self.not_master,
                            flp=self.user,
                            name='New project',
                            description='spam',
                            tasks='spam',
                            targets='spam',
                            target_group='spam',
                            schedule='spam',
                            resources='spam',
                            finance_description='spam')
     before_add = Project.objects.count()
     response = client.post('/projects/edit/1/',
                            {'name': 'some other name'})
     after_add = Project.objects.count()
     self.assertEqual(response.status_code, 200)
     self.assertEqual(before_add, after_add)
Esempio n. 30
0
    def test_unauthorised_to_report_user(self):
        before_add = Report.objects.count()
        client.login(username='******', password='******')
        for report in range(10):
            response = client.post(
                '/reports/add/', {
                    "copies-TOTAL_FORMS": 2,
                    "copies-INITIAL_FORMS": 0,
                    "copies-MAX_NUM_FORMS": 1000,
                    "addressed_to": "Hackfmi",
                    "reported_from": self.kril.pk,
                    "content": "This is a report test",
                    "signed_from": "rozovo zaiche",
                })

        after_add = Report.objects.count()
        self.assertEqual(302, response.status_code)
        self.assertEqual(before_add, after_add)
Esempio n. 31
0
 def test_edit_status_of_project_user_has_permissions(self):
     client.login(username='******', password='******')
     Project.objects.create(
         user=self.not_master,
         flp=self.user,
         name='New project',
         description='spam',
         tasks='spam',
         targets='spam',
         target_group='spam',
         schedule='spam',
         resources='spam',
         finance_description='spam')
     before_add = Project.objects.count()
     response = client.post('/projects/edit_status/1/', {
                             'status': 'approved'})
     after_add = Project.objects.count()
     self.assertEqual(response.status_code, 302)
     self.assertEqual(before_add, after_add)
Esempio n. 32
0
 def test_edit_project_from_its_creator(self):
     client.login(username='******', password='******')
     Project.objects.create(
         user=self.not_master,
         flp=self.user,
         name='New project',
         description='spam',
         tasks='spam',
         targets='spam',
         target_group='spam',
         schedule='spam',
         resources='spam',
         finance_description='spam')
     before_add = Project.objects.count()
     response = client.post('/projects/edit/1/', {
                             'name': 'some other name'})
     after_add = Project.objects.count()
     self.assertEqual(response.status_code, 200)
     self.assertEqual(before_add, after_add)
Esempio n. 33
0
    def test_search_by_status(self):
        client.login(username='******', password='******')

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        response = client.get('/projects/search/status/Неразгледан/')
        projects = Project.objects.filter(status='Неразгледан')

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Esempio n. 34
0
def superuser_client(db, factories, client):
    """
    Return a logged-in, non-API client with an authenticated ``User``
    stored in the ``user`` attribute
    """
    user = factories["users.SuperUser"]()
    assert client.login(username=user.username, password="******")
    setattr(client, "user", user)
    yield client
    delattr(client, "user")
Esempio n. 35
0
    def test_add_protocol_with_two_topics(self):
        before_add = Protocol.objects.count()
        topics_count_before = Topic.objects.count()
        client.login(username='******', password='******')
        response = client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "13/11/1992/1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "excused": self.kril.pk,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever',
                "topics-0-name": "topic",
                "topics-0-voted_for": 4,
                "topics-0-voted_against": 4,
                "topics-0-voted_abstain": 4,
                "topics-0-statement": "4",
                "topics-1-name": "topic2",
                "topics-1-voted_for": 4,
                "topics-1-voted_against": 4,
                "topics-1-voted_abstain": 4,
                "topics-1-statement": "4",
            })

        after_add = Protocol.objects.count()
        topic = Topic.objects.filter(name="topic", statement="4").exists()
        topics_count_after = Topic.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
        self.assertTrue(topic)
        self.assertEqual(topics_count_before + 2, topics_count_after)
Esempio n. 36
0
    def test_search_by_status(self):
        client.login(username='******', password='******')

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        response = client.get('/projects/search/status/Неразгледан/')
        projects = Project.objects.filter(status='Неразгледан')

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Esempio n. 37
0
    def test_show_project_by_id(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='other project name').count()

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        response = client.get('/projects/archive/review/{}/'.format(
            project.pk))

        self.assertEqual(200, response.status_code)
        self.assertEqual(project.pk, response.context['project_show'].pk)
Esempio n. 38
0
    def test_show_project_by_id(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='other project name').count()

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        response = client.get('/projects/archive/review/{}/'.format(project.pk))

        self.assertEqual(200, response.status_code)
        self.assertEqual(project.pk, response.context['project_show'].pk)
Esempio n. 39
0
    def test_change_status_impossible_from_this_user(self):
        '''this user is the project creator, but cannot edit its status'''

        client.login(username='******', password='******')
        Project.objects.create(user=self.not_master,
                               flp=self.user,
                               name='New project',
                               description='spam',
                               tasks='spam',
                               targets='spam',
                               target_group='spam',
                               schedule='spam',
                               resources='spam',
                               finance_description='spam')
        before_add = Project.objects.count()
        response = client.post('/projects/edit_status/1/',
                               {'status': 'approved'})
        after_add = Project.objects.count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_add, after_add)
Esempio n. 40
0
    def test_listing_page_of_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "information": 'this is the best protocol ever', })

        client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "13/11/1992/1235",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "information": 'this is the best protocol ever', })

        response = client.get('/protocols/archive/1/')

        after_add = Protocol.objects.count()
        topic = Topic.objects.filter(name="topic", statement="4").exists()
        topics_count_after = Topic.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, after_add)
        self.assertEqual(after_add, len(response.context['protocols']))
Esempio n. 41
0
    def test_change_status_impossible_from_this_user(self):
        '''this user is the project creator, but cannot edit its status'''

        client.login(username='******', password='******')
        Project.objects.create(
            user=self.not_master,
            flp=self.user,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')
        before_add = Project.objects.count()
        response = client.post('/projects/edit_status/1/', {
                                'status': 'approved'})
        after_add = Project.objects.count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_add, after_add)
Esempio n. 42
0
    def test_user_not_able_to_add_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        response1 = client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "13/11/1992/1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "information": 'this is the best protocol ever', })
        after_add = Protocol.objects.count()

        self.assertEqual(302, response1.status_code)
        self.assertEqual(before_add, after_add)
Esempio n. 43
0
    def test_master_can_edit_status(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(status='rejected').count()

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        response = client.post('/projects/edit_status/{}/'.format(project.pk),
                               {'status': 'rejected'})

        after_edit = Project.objects.filter(status='rejected').count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_edit + 1, after_edit)
Esempio n. 44
0
    def test_add_protocol_with_two_topics(self):
        before_add = Protocol.objects.count()
        topics_count_before = Topic.objects.count()
        client.login(username='******', password='******')
        response = client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "13/11/1992/1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "excused": self.kril.pk,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "voted_for": 2,
            "voted_against": 3,
            "voted_abstain": 0,
            "information": 'this is the best protocol ever',
            "topics-0-name": "topic",
            "topics-0-voted_for": 4,
            "topics-0-voted_against": 4,
            "topics-0-voted_abstain": 4,
            "topics-0-statement": "4",
            "topics-1-name": "topic2",
            "topics-1-voted_for": 4,
            "topics-1-voted_against": 4,
            "topics-1-voted_abstain": 4,
            "topics-1-statement": "4", })

        after_add = Protocol.objects.count()
        topic = Topic.objects.filter(name="topic", statement="4").exists()
        topics_count_after = Topic.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
        self.assertTrue(topic)
        self.assertEqual(topics_count_before + 2, topics_count_after)
Esempio n. 45
0
    def test_master_can_edit_status(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(status='rejected').count()

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        response = client.post('/projects/edit_status/{}/'.format(project.pk), {
                               'status': 'rejected'})

        after_edit = Project.objects.filter(status='rejected').count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_edit + 1, after_edit)
Esempio n. 46
0
    def test_projects_by_month_and_year(self):
        client.login(username='******', password='******')

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        year = date.today().year
        month = date.today().month

        response = client.get('/projects/archive/{}/{}/'.format(year, month))
        projects = Project.objects.filter(created_at__year=year, created_at__month=month)

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Esempio n. 47
0
    def test_user_not_able_to_add_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        response1 = client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "13/11/1992/1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "information": 'this is the best protocol ever',
            })
        after_add = Protocol.objects.count()

        self.assertEqual(302, response1.status_code)
        self.assertEqual(before_add, after_add)
Esempio n. 48
0
    def test_projects_by_month_and_year(self):
        client.login(username='******', password='******')

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        year = date.today().year
        month = date.today().month

        response = client.get('/projects/archive/{}/{}/'.format(year, month))
        projects = Project.objects.filter(created_at__year=year,
                                          created_at__month=month)

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Esempio n. 49
0
 def test_add_protocol_with_topic(self):
     before_add = Protocol.objects.count()
     topics_count_before = Topic.objects.count()
     client.login(username='******', password='******')
     response = client.post('/protocols/add/', {
         "topics-TOTAL_FORMS": 1,
         "topics-INITIAL_FORMS": 0,
         "topics-MAX_NUM_FORMS": 1000,
         "institution": self.institution.pk,
         "number": "13/11/1992/1234",
         "start_time": time(10, 0, 0),
         "scheduled_time": time(9, 0, 0),
         "quorum": 32,
         "absent": self.kril.pk,
         "attendents": self.kril.pk,
         "majority": 5,
         "current_majority": 4,
         "information": 'this is the best protocol ever',
         "topics-0-name": "topic",
         "topics-0-voted_for": 4,
         "topics-0-voted_against": 4,
         "topics-0-voted_abstain": 4,
         "topics-0-statement": "4", })
Esempio n. 50
0
    def test_complex_search(self):
        client.login(username='******', password='******')

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        Project.objects.create(user=self.not_master,
                               flp=self.not_master,
                               name='Old project',
                               description='spam',
                               tasks='spam',
                               targets='spam',
                               target_group='spam',
                               schedule='spam',
                               resources='spam',
                               finance_description='spam')

        search_data = urlencode({
            "name": "New project",
            "status": "unrevised",
            "flp": self.not_master.first_name
        })

        response = client.get('/projects/archive/?{}'.format(search_data))
        projects = Project.objects.filter(name="New project")

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Esempio n. 51
0
    def test_master_cannot_edit_project(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='other project name').count()

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        data_copy = self.test_data.copy()
        data_copy.update({'name': 'some other name'})

        response = client.post('/projects/edit/{}/'.format(project.pk), data_copy)

        after_edit = Project.objects.filter(name='other project name').count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_edit, after_edit)
Esempio n. 52
0
    def test_show_projects_archive(self):
        client.login(username='******', password='******')
        for project_number in range(10):
            project = Project.objects.create(
                user=self.not_master,
                flp=self.not_master,
                name='Project{}'.format(project_number),
                description='spam',
                tasks='spam',
                targets='spam',
                target_group='spam',
                schedule='spam',
                resources='spam',
                finance_description='spam')

            if project_number < 4:
                client.post('/projects/edit_status/{}/'.format(project.pk), {
                                'status': 'approved'})

        response = client.get('/projects/archive/')

        self.assertEqual(200, response.status_code)
        self.assertEqual(6, len(response.context['unrevised']))
        self.assertEqual(4, len(response.context['approved']))
Esempio n. 53
0
    def test_show_projects_archive(self):
        client.login(username='******', password='******')
        for project_number in range(10):
            project = Project.objects.create(
                user=self.not_master,
                flp=self.not_master,
                name='Project{}'.format(project_number),
                description='spam',
                tasks='spam',
                targets='spam',
                target_group='spam',
                schedule='spam',
                resources='spam',
                finance_description='spam')

            if project_number < 4:
                client.post('/projects/edit_status/{}/'.format(project.pk),
                            {'status': 'approved'})

        response = client.get('/projects/archive/')

        self.assertEqual(200, response.status_code)
        self.assertEqual(6, len(response.context['unrevised']))
        self.assertEqual(4, len(response.context['approved']))
Esempio n. 54
0
    def test_master_cannot_edit_project(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='other project name').count()

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        data_copy = self.test_data.copy()
        data_copy.update({'name': 'some other name'})

        response = client.post('/projects/edit/{}/'.format(project.pk),
                               data_copy)

        after_edit = Project.objects.filter(name='other project name').count()
        self.assertEqual(response.status_code, 302)
        self.assertEqual(before_edit, after_edit)
Esempio n. 55
0
 def get_client(self):
     client = APIClient()
     client.login(username=self.user.username, password='******')
     return client
Esempio n. 56
0
 def test_get_user_projects(self):
     client.login(username='******', password='******')
     response = client.get('/members/profile/')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.context['projects']), 1)
     self.assertEqual(response.context['projects'][0].pk, self.project.pk)
Esempio n. 57
0
 def get_client(self):
     client = APIClient()
     client.login(username=self.user.username, password="******")
     return client