Exemplo n.º 1
0
    def test_super_user(self):
        '''Superusers shouldn't be able to create countries.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.params)
        self.assertMethodNotAllowed(response, 'POST')
Exemplo n.º 2
0
    def test_superuser(self):
        '''It updates the delegates for a superuser.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertEqual(
            dict(response.data[0]),
            {
                'id': self.delegate1.id,
                'assignment': self.params[0]['assignment'],
                'school': self.delegate1.school.id,
                'name': unicode(self.delegate1.name),
                'email': unicode(self.delegate1.email),
                'summary': unicode(self.delegate1.summary),
                'created_at': self.delegate1.created_at.isoformat()
            },
        )
        self.assertEqual(
            dict(response.data[1]),
            {
                'id': self.delegate2.id,
                'assignment': self.params[1]['assignment'],
                'school': self.delegate2.school.id,
                'name': unicode(self.delegate2.name),
                'email': unicode(self.delegate2.email),
                'summary': unicode(self.delegate2.summary),
                'created_at': self.delegate2.created_at.isoformat()
            },
        )
Exemplo n.º 3
0
    def test_superuser(self):
        '''It finalizes the assignments for a superuser.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.assignment.id)
        self.assertDeleted(response)
Exemplo n.º 4
0
 def test_superuser(self):
     '''A superuser should be able to partially update anyone's info.'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.registration.id, self.params)
     self.assertEqual(response.data, {
         'id': self.registration.id,
         'school': self.registration.school.id,
         'conference': self.registration.conference.session,
         'registered_at': self.registration.registered_at.isoformat(),
         'is_waitlisted': self.registration.is_waitlisted,
         'num_beginner_delegates': self.registration.num_beginner_delegates,
         'num_intermediate_delegates':
         self.registration.num_intermediate_delegates,
         'num_advanced_delegates': self.registration.num_advanced_delegates,
         'num_spanish_speaking_delegates':
         self.registration.num_spanish_speaking_delegates,
         'num_chinese_speaking_delegates':
         self.registration.num_chinese_speaking_delegates,
         'waivers_completed': self.registration.waivers_completed,
         'country_preferences': self.registration.country_preference_ids,
         'committee_preferences':
         list(self.registration.committee_preferences.all()),
         'registration_comments': self.registration.registration_comments,
         'delegate_fees_owed': float(self.registration.delegate_fees_owed),
         'delegate_fees_paid': float(self.registration.delegate_fees_paid),
         'registration_fee_paid': self.registration.registration_fee_paid,
         'assignments_finalized': True,
         'modified_at': self.registration.modified_at.isoformat()
     })
Exemplo n.º 5
0
    def test_superuser(self):
        '''Superusers shouldn't be able to update committees.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.committee.id, params=self.params)
        self.assertMethodNotAllowed(response, 'PATCH')
Exemplo n.º 6
0
    def test_import(self):
        '''Test that the admin panel can import delegates. '''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        school = models.new_school()
        cm1 = models.new_committee(name='SPD')
        cm2 = models.new_committee(name='USS')
        co1 = models.new_country(name="Côte d'Ivoire")
        co2 = models.new_country(name='Barbara Boxer')
        Assignment.objects.create(committee=cm1, country=co1, school=school)
        Assignment.objects.create(committee=cm2, country=co2, school=school)

        f = TestFiles.new_csv([
            ['Name', 'Committee', 'Country', 'School'],
            ['John Doe', 'SPD', "Côte d'Ivoire", 'Test School'],
            ['Jane Doe', 'USS', 'Barbara Boxer', 'Test School'],
        ])

        with closing(f) as f:
            self.client.post(reverse('admin:core_delegate_load'), {'csv': f})

        self.assertTrue(
            Delegate.objects.filter(assignment=Assignment.objects.get(
                school=School.objects.get(name='Test School'),
                committee=Committee.objects.get(name='SPD'),
                country=Country.objects.get(name="Côte d'Ivoire")),
                                    name='John Doe').exists())
        self.assertTrue(
            Delegate.objects.filter(assignment=Assignment.objects.get(
                school=School.objects.get(name='Test School'),
                committee=Committee.objects.get(name='USS'),
                country=Country.objects.get(name='Barbara Boxer')),
                                    name='Jane Doe').exists())
Exemplo n.º 7
0
    def test_import(self):
        '''Test that the admin panel can import Assignments.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        registration = models.new_registration()
        cm1 = models.new_committee(name='SPD')
        cm2 = models.new_committee(name='USS')
        co1 = models.new_country(name="Côte d'Ivoire")
        co2 = models.new_country(name='Barbara Boxer')

        f = TestFiles.new_csv([
            ['Test School', 'SPD', "Côte d'Ivoire"],
            ['Test School', 'USS', 'Barbara Boxer']
        ])

        with closing(f) as f:
            self.client.post(reverse('admin:core_assignment_load'), {'csv': f})

        self.assertTrue(
            Assignment.objects.filter(
                registration=registration,
                committee=Committee.objects.get(name='SPD'),
                country=Country.objects.get(name="Côte d'Ivoire")).exists())
        self.assertTrue(
            Assignment.objects.filter(
                registration=registration,
                committee=Committee.objects.get(name='USS'),
                country=Country.objects.get(name='Barbara Boxer')).exists())
Exemplo n.º 8
0
    def test_superuser(self):
        '''It updates the delegates for a superuser.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertEqual(dict(response.data[0]),
            {
                'id': self.delegate1.id,
                'assignment': self.params[0]['assignment'],
                'school': self.delegate1.school.id,
                'name': unicode(self.delegate1.name),
                'email': unicode(self.delegate1.email),
                'summary': unicode(self.delegate1.summary),
                'created_at': self.delegate1.created_at.isoformat()
            },
        )
        self.assertEqual(dict(response.data[1]),
            {
                'id': self.delegate2.id,
                'assignment': self.params[1]['assignment'],
                'school': self.delegate2.school.id,
                'name': unicode(self.delegate2.name),
                'email': unicode(self.delegate2.email),
                'summary': unicode(self.delegate2.summary),
                'created_at': self.delegate2.created_at.isoformat()
            },
        )
Exemplo n.º 9
0
    def test_superuser(self):
        '''It returns the delegates for a superuser.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(params={'school_id': self.school.id})
        self.assert_delegates_equal(response, [self.delegate1, self.delegate2])
Exemplo n.º 10
0
    def test_import(self):
        '''Test that the admin panel can import committees.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        f = TestFiles.new_csv([
            ['SPD', 'Special Pôlitical and Decolonization', 2, ''],
            ['USS', 'United States Senate', 2, True]
        ])

        with closing(f) as f:
            self.client.post(reverse('admin:core_committee_load'), {'csv': f})

        self.assertTrue(Committee.objects.filter(
            name='SPD',
            full_name='Special Pôlitical and Decolonization',
            delegation_size=2,
            special=False
        ).exists())
        self.assertTrue(Committee.objects.filter(
            name='USS',
            full_name='United States Senate',
            delegation_size=2,
            special=True
        ).exists())
Exemplo n.º 11
0
    def test_super_user(self):
        '''Superusers shouldn't be able to create countries.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.params)
        self.assertMethodNotAllowed(response, 'POST')
Exemplo n.º 12
0
    def test_import(self):
        '''Test that the admin panel can import countries. '''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        f = TestFiles.new_csv([
            ['United States of America', ''],
            ['Barbara Boxer', True],
            ["Côte d'Ivoire", '']
        ])

        with closing(f) as f:
            self.client.post(reverse('admin:core_country_load'), {'csv': f})

        self.assertTrue(Country.objects.filter(
            name='United States of America',
            special=False
        ).exists())
        self.assertTrue(Country.objects.filter(
            name='Barbara Boxer',
            special=True
        ).exists())
        self.assertTrue(Country.objects.filter(
            name="Côte d'Ivoire",
            special=False
        ).exists())
Exemplo n.º 13
0
    def test_superuser(self):
        '''It should reject a request from a superuser.'''
        models.new_superuser(username='******', password='******')

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

        self.assertMethodNotAllowed(response, 'GET')
Exemplo n.º 14
0
    def test_superuser(self):
        '''It should reject a request from a superuser.'''
        models.new_superuser(username='******', password='******')

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

        self.assertMethodNotAllowed(response, 'GET')
Exemplo n.º 15
0
    def test_superuser(self):
        '''This should allow  a superuser to change school data.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        response = self.get_response(self.school.id, params=self.params)
        self.school = School.objects.get(id=self.school.id)

        self.assertEqual(response.data['name'], self.school.name)
        self.assertEqual(response.data['city'], self.school.city)
Exemplo n.º 16
0
    def test_superuser(self):
        '''A superuser should be allowed to change information about a user.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id, params=self.params)
        user = User.objects.get(id=self.user.id)
        self.assertEqual(response.data['first_name'], user.first_name)
        self.assertEqual(response.data['last_name'], user.last_name)
Exemplo n.º 17
0
    def test_superuser(self):
        '''This should allow  a superuser to change school data.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        response = self.get_response(self.school.id, params=self.params)
        self.school = School.objects.get(id=self.school.id)

        self.assertEqual(response.data['name'], self.school.name)
        self.assertEqual(response.data['city'], self.school.city)
Exemplo n.º 18
0
    def test_superuser(self):
        '''A superuser should be allowed to change information about a user.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id, params=self.params)
        user = User.objects.get(id=self.user.id)
        self.assertEqual(response.data['first_name'], user.first_name)
        self.assertEqual(response.data['last_name'], user.last_name)
Exemplo n.º 19
0
 def test_superuser(self):
     '''Superuser can create feedback'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(params=self.params)
     response.data.pop('id')
     self.assertEqual(response.data, {
         "committee": self.committee_1.id,
         "comment": self.params['comment'],
     })
Exemplo n.º 20
0
 def test_superuser(self):
     '''Tests superuser can get secretariat information'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.sm1.id)
     response.data.pop('id')
     self.assertEqual(response.data, {
         'name': self.name,
         'committee': self.committee.id,
         'is_head_chair': self.is_head_chair
     })
Exemplo n.º 21
0
    def test_preference_export(self):
        '''Tests that the admin panel can export registration data.'''
        registration = models.new_registration()

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

        response = self.client.get(reverse('admin:core_registration_info'))

        header = [
            "Registration Time", "School Name", "Total Number of Delegates",
            "Beginners", "Intermediates", "Advanced", "Spanish Speakers",
            "Chinese Speakers", "Assignments Finalized", "Waivers Complete",
            "Delegate Fees Paid", "Delegate Fees Owed",
            "Paid Registration Fee?", "Country 1", "Country 2", "Country 3",
            "Country 4", "Country 5", "Country 6", "Country 7", "Country 8",
            "Country 9", "Country 10", "Committee Preferences",
            "Registration Comments"
        ]

        fields_csv = ",".join(map(str, header)) + "\r\n"

        country_preferences = [
            cp for cp in registration.country_preferences.all().order_by(
                'countrypreference')
        ]
        country_preferences += [''] * (10 - len(country_preferences))
        committee_preferences = [
            ', '.join(cp.name
                      for cp in registration.committee_preferences.all())
        ]

        fields = [
            registration.registered_at, registration.school.name,
            registration.num_beginner_delegates +
            registration.num_intermediate_delegates +
            registration.num_advanced_delegates,
            registration.num_beginner_delegates,
            registration.num_intermediate_delegates,
            registration.num_advanced_delegates,
            registration.num_spanish_speaking_delegates,
            registration.num_chinese_speaking_delegates,
            registration.assignments_finalized, registration.waivers_completed,
            registration.delegate_fees_paid, registration.delegate_fees_owed,
            registration.registration_fee_paid
        ]
        fields.extend(country_preferences)
        fields.extend(committee_preferences)
        fields.extend(registration.registration_comments)

        fields_csv += ','.join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-3].decode('utf-8'))
Exemplo n.º 22
0
    def test_superuser(self):
        '''Superusers should be able to create assignments.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(params=self.params)
        response.data.pop('id')
        self.assertEqual(response.data, {
            "committee" : self.committee.id,
            "country" : self.country.id,
            "school" : self.school.id,
            "rejected" : True,
        })
Exemplo n.º 23
0
    def test_preference_export(self):
        '''Tests that the admin panel can export registration data.'''
        registration = models.new_registration()

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

        response = self.client.get(reverse('admin:core_registration_info'))

        header = [
            "Registration Time", "School Name", "Total Number of Delegates",
            "Beginners", "Intermediates", "Advanced", "Spanish Speakers",
            "Chinese Speakers",  "Assignments Finalized", "Waivers Complete", 
            "Delegate Fees Paid", "Delegate Fees Owed", "Paid Registration Fee?", 
            "Country 1", "Country 2", "Country 3", "Country 4", "Country 5", 
            "Country 6", "Country 7", "Country 8", "Country 9", "Country 10", 
            "Committee Preferences", "Registration Comments"
        ]

        fields_csv = ",".join(map(str, header)) + "\r\n"

        country_preferences = [cp
                               for cp in registration.country_preferences.all(
                               ).order_by('countrypreference')]
        country_preferences += [''] * (10 - len(country_preferences))
        committee_preferences = [', '.join(
            cp.name for cp in registration.committee_preferences.all())]

        fields = [
            registration.registered_at,
            registration.school.name,
            registration.num_beginner_delegates +
            registration.num_intermediate_delegates +
            registration.num_advanced_delegates,
            registration.num_beginner_delegates,
            registration.num_intermediate_delegates,
            registration.num_advanced_delegates,
            registration.num_spanish_speaking_delegates,
            registration.num_chinese_speaking_delegates,
            registration.assignments_finalized,
            registration.waivers_completed,
            registration.delegate_fees_paid,
            registration.delegate_fees_owed,
            registration.registration_fee_paid
        ]
        fields.extend(country_preferences)
        fields.extend(committee_preferences)
        fields.extend(registration.registration_comments)

        fields_csv += ','.join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-3])
Exemplo n.º 24
0
    def test_superuser_fail(self):
        '''
        It doesn't update the delegates for the superuser if fields are invalid.
        '''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        self.params = [
            {'id': self.delegate1.id,
             'assignment': self.faulty_assignment.id},
            {'id': self.delegate2.id,
             'assignment': self.new_assignment.id}
        ]

        self.assertRaises(ValidationError, self.get_response, self.school.id)
Exemplo n.º 25
0
    def test_superuser(self):
        '''Superusers should be able to create assignments.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(params=self.params)
        response.data.pop('id')
        self.assertEqual(
            response.data, {
                "committee": self.committee.id,
                "country": self.country.id,
                "school": self.school.id,
                "rejected": True,
            })
Exemplo n.º 26
0
 def test_superuser(self):
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(
         params={
             'school_id': self.school.id,
             'conference_session': Conference.get_current()
         })
     self.assertEqual(len(response.data), 1)
     self.assertEqual(
         dict(response.data[0]), {
             'id':
             self.registration.id,
             'school':
             self.registration.school_id,
             'conference':
             self.registration.conference_id,
             'registered_at':
             self.registration.registered_at.isoformat(),
             'is_waitlisted':
             self.registration.is_waitlisted,
             'num_beginner_delegates':
             self.registration.num_beginner_delegates,
             'num_intermediate_delegates':
             self.registration.num_intermediate_delegates,
             'num_advanced_delegates':
             self.registration.num_advanced_delegates,
             'num_spanish_speaking_delegates':
             self.registration.num_spanish_speaking_delegates,
             'num_chinese_speaking_delegates':
             self.registration.num_chinese_speaking_delegates,
             'waivers_completed':
             self.registration.waivers_completed,
             'country_preferences':
             self.registration.country_preference_ids,
             'committee_preferences':
             list(self.registration.committee_preferences.all()),
             'registration_comments':
             self.registration.registration_comments,
             'delegate_fees_owed':
             float(self.registration.delegate_fees_owed),
             'delegate_fees_paid':
             float(self.registration.delegate_fees_paid),
             'registration_fee_paid':
             self.registration.registration_fee_paid,
             'assignments_finalized':
             self.registration.assignments_finalized,
             'modified_at':
             self.registration.modified_at.isoformat()
         })
Exemplo n.º 27
0
    def test_superuser(self):
        '''It updates the delegates for a superuser.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertEqual(
            dict(response.data[0]),
            {
                'id': self.delegate1.id,
                'assignment': self.params[0]['assignment'],
                'school': self.delegate1.school.id,
                'name': str(self.delegate1.name),
                'email': str(self.delegate1.email),
                'summary': str(self.delegate1.summary),
                'published_summary': str(self.delegate1.published_summary),
                'created_at': self.delegate1.created_at.isoformat(),
                'voting': self.delegate1.voting,
                "session_one": self.delegate1.session_one,
                "session_two": self.delegate1.session_two,
                "session_three": self.delegate1.session_three,
                "session_four": self.delegate1.session_four,
                "committee_feedback_submitted":
                self.delegate1.committee_feedback_submitted,
                "waiver_submitted": self.delegate1.waiver_submitted
            },
        )
        self.assertEqual(
            dict(response.data[1]),
            {
                'id': self.delegate2.id,
                'assignment': self.params[1]['assignment'],
                'school': self.delegate2.school.id,
                'name': str(self.delegate2.name),
                'email': str(self.delegate2.email),
                'summary': str(self.delegate2.summary),
                'published_summary': str(self.delegate2.published_summary),
                'created_at': self.delegate2.created_at.isoformat(),
                'voting': self.delegate2.voting,
                "session_one": self.delegate2.session_one,
                "session_two": self.delegate2.session_two,
                "session_three": self.delegate2.session_three,
                "session_four": self.delegate2.session_four,
                "committee_feedback_submitted":
                self.delegate2.committee_feedback_submitted,
                "waiver_submitted": self.delegate2.waiver_submitted
            },
        )
Exemplo n.º 28
0
    def test_preference_export(self):
        '''Test that the admin panel can properly export school preferences.'''
        models.new_user(username='******', password='******')
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        school = models.new_school()
        self.client.logout()
        self.client.login(username='******', password='******')

        response = self.client.get(reverse('admin:core_school_preferences'))

        self.assertTrue(response)

        header = [
            "Name", "Assignments Requested", "Beginners", "Intermediates",
            "Advanced", "Spanish Speakers", "Chinese Speakers", "Country 1",
            "Country 2", "Country 3", "Country 4", "Country 5", "Country 6",
            "Country 7", "Country 8", "Country 9", "Country 10",
            "Committee Preferences", "Registration Comments"
        ]

        fields_csv = ",".join(map(str, header)) + "\r\n"

        countryprefs = [
            c for c in school.countrypreferences.all().order_by(
                'countrypreference')
        ]
        countryprefs += [''] * (10 - len(countryprefs))
        committeeprefs = [
            ', '.join([c.name for c in school.committeepreferences.all()])
        ]

        fields = [
            school.name,
            school.beginner_delegates + school.intermediate_delegates +
            school.advanced_delegates,
            school.beginner_delegates,
            school.intermediate_delegates,
            school.advanced_delegates,
            school.spanish_speaking_delegates,
            school.chinese_speaking_delegates,
        ]
        fields.extend(countryprefs)
        fields.extend(committeeprefs)
        fields.append(school.registration_comments)

        fields_csv += ",".join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-2])
Exemplo n.º 29
0
    def test_superuser(self):
        '''It should allow a superuser to list all users.'''
        user1 = models.new_superuser(username='******', password='******')
        user2 = models.new_user(username='******')
        self.client.login(username='******', password='******')

        response = self.get_response()
        self.assertEqual(response.data, [
            {'id': user1.id,
             'username': user1.username,
             'first_name': user1.first_name,
             'last_name': user1.last_name,
             'user_type': user1.user_type,
             'school': user1.school_id,
             'committee': user1.committee_id,
             'delegate': user1.delegate_id},
            {'id': user2.id,
             'username': user2.username,
             'first_name': user2.first_name,
             'last_name': user2.last_name,
             'user_type': user2.user_type,
             'school': user2.school_id,
             'committee': user2.committee_id,
             'delegate': user2.delegate_id},
        ])
Exemplo n.º 30
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.rubric.id, params=self.params)
     self.assertEqual(response.data, {
         "id": self.paper.id,
         "grade_category_1": self.params['grade_category_1'],
         "grade_value_1": self.params['grade_value_1'],
         "grade_category_2": self.rubric.grade_category_2,
         "grade_value_2": self.rubric.grade_value_2,
         "grade_category_3": self.rubric.grade_category_3,
         "grade_value_3": self.rubric.grade_value_3,
         "grade_category_4": self.rubric.grade_category_4,
         "grade_value_4": self.rubric.grade_value_4,
         "grade_category_5": self.rubric.grade_category_5,
         "grade_value_5": self.rubric.grade_value_5,
         "grade_t2_category_1": self.rubric.grade_t2_category_2,
         "grade_t2_value_1": self.rubric.grade_t2_value_2,
         "grade_t2_category_2": self.rubric.grade_category_2,
         "grade_t2_value_2": self.rubric.grade_value_2,
         "grade_t2_category_3": self.rubric.grade_category_3,
         "grade_t2_value_3": self.rubric.grade_value_3,
         "grade_t2_category_4": self.rubric.grade_category_4,
         "grade_t2_value_4": self.rubric.grade_value_4,
         "grade_t2_category_5": self.rubric.grade_category_5,
         "grade_t2_value_5": self.rubric.grade_value_5,
         "use_topic_2": self.rubric.use_topic_2,
         "topic_one": self.rubric.topic_one,
         "topic_two": self.rubric.topic_two,
     })
Exemplo n.º 31
0
 def test_superuser(self):
     '''Superuser can retrieve any feedback'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response_1 = self.get_response(self.feedback_1.id)
     response_1.data.pop('id')
     self.assertEqual(response_1.data, {
         'committee': self.committee_1.id,
         'comment': self.feedback_1.comment
     })
     response_2 = self.get_response(self.feedback_2.id)
     response_2.data.pop('id')
     self.assertEqual(response_2.data, {
         'committee': self.committee_2.id,
         'comment': self.feedback_2.comment
     })
Exemplo n.º 32
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.rubric.id, params=self.params)
     self.assertEqual(
         response.data, {
             "id": self.paper.id,
             "grade_category_1": self.params['grade_category_1'],
             "grade_value_1": self.params['grade_value_1'],
             "grade_category_2": self.rubric.grade_category_2,
             "grade_value_2": self.rubric.grade_value_2,
             "grade_category_3": self.rubric.grade_category_3,
             "grade_value_3": self.rubric.grade_value_3,
             "grade_category_4": self.rubric.grade_category_4,
             "grade_value_4": self.rubric.grade_value_4,
             "grade_category_5": self.rubric.grade_category_5,
             "grade_value_5": self.rubric.grade_value_5,
             "grade_t2_category_1": self.rubric.grade_t2_category_2,
             "grade_t2_value_1": self.rubric.grade_t2_value_2,
             "grade_t2_category_2": self.rubric.grade_category_2,
             "grade_t2_value_2": self.rubric.grade_value_2,
             "grade_t2_category_3": self.rubric.grade_category_3,
             "grade_t2_value_3": self.rubric.grade_value_3,
             "grade_t2_category_4": self.rubric.grade_category_4,
             "grade_t2_value_4": self.rubric.grade_value_4,
             "grade_t2_category_5": self.rubric.grade_category_5,
             "grade_t2_value_5": self.rubric.grade_value_5,
             "use_topic_2": self.rubric.use_topic_2,
             "topic_one": self.rubric.topic_one,
             "topic_two": self.rubric.topic_two,
         })
Exemplo n.º 33
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.assignment.id)
     self.assertEqual(response.data, {
         "id": self.assignment.id,
         "committee": self.assignment.committee.id,
         "country": self.assignment.country.id,
         "registration": self.registration.id,
         "paper": OrderedDict(
             [('id', self.assignment.paper.id),
              ('file', self.assignment.paper.file),
              ('graded_file', self.assignment.paper.graded_file),
              ('graded', self.assignment.paper.graded),
              ('score_1', self.assignment.paper.score_1),
              ('score_2', self.assignment.paper.score_2),
              ('score_3', self.assignment.paper.score_3),
              ('score_4', self.assignment.paper.score_4),
              ('score_5', self.assignment.paper.score_5),
              ('score_t2_1', self.assignment.paper.score_t2_1),
              ('score_t2_2', self.assignment.paper.score_t2_2),
              ('score_t2_3', self.assignment.paper.score_t2_3),
              ('score_t2_4', self.assignment.paper.score_t2_4),
              ('score_t2_5', self.assignment.paper.score_t2_5),
              ("submission_date", self.assignment.paper.submission_date)]),
         "rejected": True,
     })
Exemplo n.º 34
0
    def test_superuser(self):
        '''It updates the delegates for a superuser.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertEqual(
            dict(response.data[0]),
            {
                'id': self.delegate1.id,
                'assignment': self.params[0]['assignment'],
                'school': self.delegate1.school.id,
                'name': unicode(self.delegate1.name),
                'email': unicode(self.delegate1.email),
                'summary': unicode(self.delegate1.summary),
                'published_summary': unicode(self.delegate1.published_summary),
                'created_at': self.delegate1.created_at.isoformat(),
                'voting': self.delegate1.voting,
                "session_one": self.delegate1.session_one,
                "session_two": self.delegate1.session_two,
                "session_three": self.delegate1.session_three,
                "session_four": self.delegate1.session_four,
                "committee_feedback_submitted":
                self.delegate1.committee_feedback_submitted,
                "waiver_submitted": self.delegate1.waiver_submitted
            }, )
        self.assertEqual(
            dict(response.data[1]),
            {
                'id': self.delegate2.id,
                'assignment': self.params[1]['assignment'],
                'school': self.delegate2.school.id,
                'name': unicode(self.delegate2.name),
                'email': unicode(self.delegate2.email),
                'summary': unicode(self.delegate2.summary),
                'published_summary': unicode(self.delegate2.published_summary),
                'created_at': self.delegate2.created_at.isoformat(),
                'voting': self.delegate2.voting,
                "session_one": self.delegate2.session_one,
                "session_two": self.delegate2.session_two,
                "session_three": self.delegate2.session_three,
                "session_four": self.delegate2.session_four,
                "committee_feedback_submitted":
                self.delegate2.committee_feedback_submitted,
                "waiver_submitted": self.delegate2.waiver_submitted
            }, )
Exemplo n.º 35
0
 def test_superuser(self):
     '''A superuser should be able to partially update anyone's info.'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.registration.id, self.params)
     self.assertEqual(
         response.data, {
             'id':
             self.registration.id,
             'school':
             self.registration.school.id,
             'conference':
             self.registration.conference.session,
             'registered_at':
             self.registration.registered_at.isoformat(),
             'is_waitlisted':
             self.registration.is_waitlisted,
             'num_beginner_delegates':
             self.registration.num_beginner_delegates,
             'num_intermediate_delegates':
             self.registration.num_intermediate_delegates,
             'num_advanced_delegates':
             self.registration.num_advanced_delegates,
             'num_spanish_speaking_delegates':
             self.registration.num_spanish_speaking_delegates,
             'num_chinese_speaking_delegates':
             self.registration.num_chinese_speaking_delegates,
             'waivers_completed':
             self.registration.waivers_completed,
             'country_preferences':
             self.registration.country_preference_ids,
             'committee_preferences':
             list(self.registration.committee_preferences.all()),
             'registration_comments':
             self.registration.registration_comments,
             'delegate_fees_owed':
             float(self.registration.delegate_fees_owed),
             'delegate_fees_paid':
             float(self.registration.delegate_fees_paid),
             'registration_fee_paid':
             self.registration.registration_fee_paid,
             'assignments_finalized':
             True,
             'modified_at':
             self.registration.modified_at.isoformat()
         })
Exemplo n.º 36
0
    def test_preference_export(self):
        '''Test that the admin panel can properly export school preferences.'''
        models.new_user(username='******', password='******')
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        school = models.new_school()
        self.client.logout()
        self.client.login(username='******', password='******')

        response = self.client.get(reverse('admin:core_school_preferences'))

        self.assertTrue(response)

        header = [
            "Name", "Assignments Requested", "Beginners", "Intermediates",
            "Advanced", "Spanish Speakers", "Chinese Speakers", "Country 1",
            "Country 2", "Country 3", "Country 4", "Country 5", "Country 6",
            "Country 7", "Country 8", "Country 9", "Country 10",
            "Committee Preferences", "Registration Comments"
        ]

        fields_csv = ",".join(map(str, header)) + "\r\n"

        countryprefs = [c
                        for c in school.countrypreferences.all().order_by(
                            'countrypreference')]
        countryprefs += [''] * (10 - len(countryprefs))
        committeeprefs = [', '.join(
            [c.name for c in school.committeepreferences.all()])]

        fields = [
            school.name,
            school.beginner_delegates + school.intermediate_delegates +
            school.advanced_delegates,
            school.beginner_delegates,
            school.intermediate_delegates,
            school.advanced_delegates,
            school.spanish_speaking_delegates,
            school.chinese_speaking_delegates,
        ]
        fields.extend(countryprefs)
        fields.extend(committeeprefs)
        fields.append(school.registration_comments)

        fields_csv += ",".join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-2])
Exemplo n.º 37
0
 def test_superuser(self):
     '''Superuser can create feedback'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(params=self.params)
     response.data.pop('id')
     self.assertEqual(
         response.data, {
             "committee": self.committee_1.id,
             "comment": self.params['comment'],
             'rating': self.params['rating'],
             'chair_1_name': self.params['chair_1_name'],
             'chair_1_comment': self.params['chair_1_comment'],
             'chair_1_rating': self.params['chair_1_rating'],
             'chair_2_name': self.params['chair_2_name'],
             'chair_2_comment': self.params['chair_2_comment'],
             'chair_2_rating': self.params['chair_2_rating'],
             'chair_3_name': self.params['chair_3_name'],
             'chair_3_comment': self.params['chair_3_comment'],
             'chair_3_rating': self.params['chair_3_rating'],
             'chair_4_name': self.params['chair_4_name'],
             'chair_4_comment': self.params['chair_4_comment'],
             'chair_4_rating': self.params['chair_4_rating'],
             'chair_5_name': self.params['chair_5_name'],
             'chair_5_comment': self.params['chair_5_comment'],
             'chair_5_rating': self.params['chair_5_rating'],
             'chair_6_name': self.params['chair_6_name'],
             'chair_6_comment': self.params['chair_6_comment'],
             'chair_6_rating': self.params['chair_6_rating'],
             'chair_7_name': self.params['chair_7_name'],
             'chair_7_comment': self.params['chair_7_comment'],
             'chair_7_rating': self.params['chair_7_rating'],
             'chair_8_name': self.params['chair_8_name'],
             'chair_8_comment': self.params['chair_8_comment'],
             'chair_8_rating': self.params['chair_8_rating'],
             'chair_9_name': self.params['chair_9_name'],
             'chair_9_comment': self.params['chair_9_comment'],
             'chair_9_rating': self.params['chair_9_rating'],
             'chair_10_name': self.params['chair_10_name'],
             'chair_10_comment': self.params['chair_10_comment'],
             'chair_10_rating': self.params['chair_10_rating'],
         })
Exemplo n.º 38
0
    def test_import(self):
        '''Test that the admin panel can import countries. '''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        f = TestFiles.new_csv([['United States of America', ''],
                               ['Barbara Boxer', True], ["Côte d'Ivoire", '']])

        with closing(f) as f:
            self.client.post(reverse('admin:core_country_load'), {'csv': f})

        self.assertTrue(
            Country.objects.filter(name='United States of America',
                                   special=False).exists())
        self.assertTrue(
            Country.objects.filter(name='Barbara Boxer',
                                   special=True).exists())
        self.assertTrue(
            Country.objects.filter(name="Côte d'Ivoire",
                                   special=False).exists())
Exemplo n.º 39
0
 def test_superuser(self):
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(params={'school_id': self.school.id,
                                          'conference_session':
                                          Conference.get_current()})
     self.assertEqual(len(response.data), 1)
     self.assertEqual(
         dict(response.data[0]), {
             'id': self.registration.id,
             'school': self.registration.school_id,
             'conference': self.registration.conference_id,
             'registered_at': self.registration.registered_at.isoformat(),
             'is_waitlisted': self.registration.is_waitlisted,
             'num_beginner_delegates':
             self.registration.num_beginner_delegates,
             'num_intermediate_delegates':
             self.registration.num_intermediate_delegates,
             'num_advanced_delegates':
             self.registration.num_advanced_delegates,
             'num_spanish_speaking_delegates':
             self.registration.num_spanish_speaking_delegates,
             'num_chinese_speaking_delegates':
             self.registration.num_chinese_speaking_delegates,
             'waivers_completed': self.registration.waivers_completed,
             'country_preferences':
             self.registration.country_preference_ids,
             'committee_preferences':
             list(self.registration.committee_preferences.all()),
             'registration_comments':
             self.registration.registration_comments,
             'delegate_fees_owed':
             float(self.registration.delegate_fees_owed),
             'delegate_fees_paid':
             float(self.registration.delegate_fees_paid),
             'registration_fee_paid':
             self.registration.registration_fee_paid,
             'assignments_finalized':
             self.registration.assignments_finalized,
             'modified_at': self.registration.modified_at.isoformat()
         })
Exemplo n.º 40
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.assignment.id)
     self.assertEqual(response.data, {
         "id" : self.assignment.id,
         "committee" : self.assignment.committee.id,
         "country" : self.assignment.country.id,
         "school" : self.school.id,
         "rejected" : True,
     })
Exemplo n.º 41
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.assignment.id)
     self.assertEqual(
         response.data, {
             "id": self.assignment.id,
             "committee": self.assignment.committee.id,
             "country": self.assignment.country.id,
             "school": self.school.id,
             "rejected": True,
         })
Exemplo n.º 42
0
    def test_import(self):
        '''Test that the admin panel can import committees.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        committee = models.new_committee(name='ICJ')

        f = TestFiles.new_csv([['Trent Gomberg', 'ICJ', ''],
                               ['Ali Maloney', 'ICJ', 'TRUE']])

        with closing(f) as f:
            self.client.post(reverse('admin:core_secretariatmember_load'),
                             {'csv': f})

        self.assertTrue(
            SecretariatMember.objects.filter(name='Trent Gomberg',
                                             committee=committee.id,
                                             is_head_chair=False).exists())
        self.assertTrue(
            SecretariatMember.objects.filter(name='Ali Maloney',
                                             committee=committee.id,
                                             is_head_chair=True).exists())
Exemplo n.º 43
0
 def test_superuser(self):
     '''Superuser can retrieve all feedback'''
     models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response_1 = self.get_response(
         params={'committee_id': self.committee_1.id})
     self.assertEqual(response_1.data, [{
         'id': self.feedback_1.id,
         'committee': self.committee_1.id,
         'comment': self.feedback_1.comment
     }, {
         'id': self.feedback_2.id,
         'committee': self.committee_1.id,
         'comment': self.feedback_2.comment
     }])
     response_2 = self.get_response(
         params={'committee_id': self.committee_2.id})
     self.assertEqual(response_2.data, [{
         'id': self.feedback_3.id,
         'committee': self.committee_2.id,
         'comment': self.feedback_3.comment
     }])
Exemplo n.º 44
0
    def test_import(self):
        '''Test that the admin panel can import delegates. '''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        registration = models.new_registration()
        cm1 = models.new_committee(name='SPD')
        cm2 = models.new_committee(name='USS')
        co1 = models.new_country(name="Côte d'Ivoire")
        co2 = models.new_country(name='Barbara Boxer')
        Assignment.objects.create(
            committee=cm1, country=co1, registration=registration)
        Assignment.objects.create(
            committee=cm2, country=co2, registration=registration)

        f = TestFiles.new_csv([
            ['Name', 'Committee', 'Country', 'School'],
            ['John Doe', 'SPD', "Côte d'Ivoire", 'Test School'],
            ['Jane Doe', 'USS', 'Barbara Boxer', 'Test School'],
        ])

        with closing(f) as f:
            self.client.post(reverse('admin:core_delegate_load'), {'csv': f})

        self.assertTrue(
            Delegate.objects.filter(
                assignment=Assignment.objects.get(
                    registration=registration,
                    committee=Committee.objects.get(name='SPD'),
                    country=Country.objects.get(name="Côte d'Ivoire")),
                name='John Doe').exists())
        self.assertTrue(
            Delegate.objects.filter(
                assignment=Assignment.objects.get(
                    registration=registration,
                    committee=Committee.objects.get(name='USS'),
                    country=Country.objects.get(name='Barbara Boxer')),
                name='Jane Doe').exists())
Exemplo n.º 45
0
    def test_import(self):
        '''Test that the admin panel can import committees.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        f = TestFiles.new_csv(
            [['SPD', 'Special Pôlitical and Decolonization', 2, ''],
             ['USS', 'United States Senate', 2, True]])

        with closing(f) as f:
            self.client.post(reverse('admin:core_committee_load'), {'csv': f})

        self.assertTrue(
            Committee.objects.filter(
                name='SPD',
                full_name='Special Pôlitical and Decolonization',
                delegation_size=2,
                special=False).exists())
        self.assertTrue(
            Committee.objects.filter(name='USS',
                                     full_name='United States Senate',
                                     delegation_size=2,
                                     special=True).exists())
Exemplo n.º 46
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.delegate.id, params=self.params)
     response.data.pop('created_at')
     self.assertEqual(response.data, {
         "id" : self.delegate.id,
         "assignment" : self.assignment.id,
         "school" : self.school.id,
         "name" : unicode(self.params['name']),
         "email" : unicode(self.params['email']),
         "summary" : unicode(self.params['summary']),}
     )
Exemplo n.º 47
0
    def test_superuser(self):
        '''Tests superuser can get secretariat information'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        response1 = self.get_response()
        self.assertEqual(response1.data, [])

        params2 = {'committee_id': self.empty_committee.id}
        response2 = self.get_response(params=params2)
        self.assertEqual(response2.data, [])

        params3 = {'committee_id': self.committee1.id}
        response3 = self.get_response(params=params3)
        self.assertEqual(response3.data, [
            {
                'id': self.sm1.id,
                'name': self.name1,
                'committee': self.committee1.id,
                'is_head_chair': self.is_head_chair1
            }, {
                'id': self.sm3.id,
                'name': self.name3,
                'committee': self.committee1.id,
                'is_head_chair': self.is_head_chair3
            }
        ])

        params4 = {'committee_id': self.committee2.id}
        resposne4 = self.get_response(params=params4)
        self.assertEqual(resposne4.data, [
            {
                'id': self.sm2.id,
                'name': self.name2,
                'committee': self.committee2.id,
                'is_head_chair': self.is_head_chair2
            }
        ])
Exemplo n.º 48
0
    def test_import(self):
        '''Test that the admin panel can import committees.'''
        models.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        committee = models.new_committee(name='ICJ')

        f = TestFiles.new_csv([
            ['Trent Gomberg', 'ICJ', ''], ['Ali Maloney', 'ICJ', 'TRUE']
        ])

        with closing(f) as f:
            self.client.post(
                reverse('admin:core_secretariatmember_load'), {'csv': f})

        self.assertTrue(
            SecretariatMember.objects.filter(
                name='Trent Gomberg',
                committee=committee.id,
                is_head_chair=False).exists())
        self.assertTrue(
            SecretariatMember.objects.filter(
                name='Ali Maloney', committee=committee.id,
                is_head_chair=True).exists())
Exemplo n.º 49
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.delegate.id, params=self.params)
     response.data.pop('created_at')
     self.assertEqual(
         response.data, {
             "id": self.delegate.id,
             "assignment": self.assignment.id,
             "school": self.school.id,
             "name": unicode(self.params['name']),
             "email": unicode(self.params['email']),
             "summary": unicode(self.params['summary']),
         })
Exemplo n.º 50
0
    def test_superuser(self):
        '''It should return the correct fields for a superuser.'''
        user1 = models.new_user(username='******')
        user2 = models.new_superuser(username='******', password='******')

        self.client.login(username='******', password='******')
        response = self.get_response(user1.id)

        self.assertEqual(
            response.data, {
                'id': user1.id,
                'username': user1.username,
                'first_name': user1.first_name,
                'last_name': user1.last_name,
                'user_type': user1.user_type,
                'school': user1.school_id,
                'committee': user1.committee_id
            })
Exemplo n.º 51
0
    def test_superuser(self):
        '''It should return the correct fields for a superuser.'''
        user1 = models.new_user(username='******')
        user2 = models.new_superuser(username='******', password='******')

        self.client.login(username='******', password='******')
        response = self.get_response(user1.id)

        self.assertEqual(response.data, {
            'id': user1.id,
            'username': user1.username,
            'first_name': user1.first_name,
            'last_name': user1.last_name,
            'user_type': user1.user_type,
            'school': user1.school_id,
            'committee': user1.committee_id,
            'delegate': user1.delegate_id
        })
Exemplo n.º 52
0
 def test_superuser(self):
     '''Should allow superuser to create delegate.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(params=self.params)
     response.data.pop('created_at')
     response.data.pop('id')
     self.assertEqual(response.data, {
         "assignment": self.assignment.id,
         "school": self.school.id,
         "name": unicode(self.params['name']),
         "email": unicode(self.params['email']),
         "summary": unicode(self.params['summary']),
         "published_summary": unicode(self.params['published_summary']),
         "voting": False,
         "session_one": False,
         "session_two": False,
         "session_three": False,
         "session_four": False,
         "committee_feedback_submitted": False,
         "waiver_submitted": False
     })
Exemplo n.º 53
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = models.new_superuser(username='******', password='******')
     self.client.login(username='******', password='******')
     response = self.get_response(self.paper.id, params=self.params)
     self.assertEqual(response.data, {
         "id": self.paper.id,
         "score_1": self.params['score_1'],
         "score_2": self.params['score_2'],
         "score_3": self.paper.score_3,
         "score_4": self.paper.score_4,
         "score_5": self.paper.score_5,
         "score_t2_1": self.paper.score_t2_1,
         "score_t2_2": self.paper.score_t2_2,
         "score_t2_3": self.paper.score_t2_3,
         "score_t2_4": self.paper.score_t2_4,
         "score_t2_5": self.paper.score_t2_5,
         "graded": self.paper.graded,
         "graded_file": self.paper.graded_file,
         "file": self.paper.file,
         "submission_date": self.paper.submission_date
     })