Пример #1
0
 def test_uniqueness(self):
     '''Is defined uniquely by its school and conference.'''
     s = models.new_school()
     c = Conference.get_current()
     r1 = models.new_registration(school=s, conference=c)
     with self.assertRaises(IntegrityError):
         r2 = models.new_registration(school=s, conference=c)
Пример #2
0
 def test_uniqueness(self):
     '''Is defined uniquely by its school and conference.'''
     s = models.new_school()
     c = Conference.get_current()
     r1 = models.new_registration(school=s, conference=c)
     with self.assertRaises(IntegrityError):
         r2 = models.new_registration(school=s, conference=c)
Пример #3
0
    def test_update_waitlist(self):
        '''New registrations should be waitlisted based on the conference waitlist field.'''
        r1 = models.new_registration()
        self.assertFalse(r1.is_waitlisted)

        conference = Conference.get_current()
        conference.waitlist_reg = True
        conference.save()

        r1.save()
        self.assertFalse(r1.is_waitlisted)
        r2 = models.new_registration()
        self.assertTrue(r2.is_waitlisted)
Пример #4
0
    def test_update_waitlist(self):
        '''New registrations should be waitlisted based on the conference waitlist field.'''
        r1 = models.new_registration()
        self.assertFalse(r1.is_waitlisted)

        conference = Conference.get_current()
        conference.waitlist_reg = True
        conference.save()

        r1.save()
        self.assertFalse(r1.is_waitlisted)
        r2 = models.new_registration()
        self.assertTrue(r2.is_waitlisted)
Пример #5
0
    def setUp(self):
        self.advisor = models.new_user(username='******', password='******')
        self.advisor2 = models.new_user(
            username='******', password='******')
        self.chair = models.new_user(
            username='******', password='******', user_type=User.TYPE_CHAIR)
        self.delegate_user = models.new_user(
            username='******',
            password='******',
            user_type=User.TYPE_DELEGATE)
        self.school = models.new_school(user=self.advisor)
        self.school2 = models.new_school(user=self.advisor2)
        self.registration = models.new_registration(school=self.school)
        self.registration2 = models.new_registration(school=self.school2)
        self.committee = models.new_committee(user=self.chair)

        self.assignment1 = models.new_assignment(
            registration=self.registration, committee=self.committee)
        self.assignment2 = models.new_assignment(
            registration=self.registration)
        self.assignment3 = models.new_assignment(
            registration=self.registration2, committee=self.committee)
        self.new_assignment = models.new_assignment(
            registration=self.registration)
        self.new_assignment2 = models.new_assignment(
            registration=self.registration2)
        self.faulty_assignment = models.new_assignment()

        self.delegate1 = models.new_delegate(
            name="Nathaniel Parke",
            school=self.school,
            assignment=self.assignment1)

        self.delegate2 = models.new_delegate(
            name='Trevor Dowds',
            school=self.school,
            assignment=self.assignment2)

        self.delegate3 = models.new_delegate(
            name='Kunal Mehta',
            school=self.school2,
            assignment=self.assignment3)

        self.params = [
            {'id': self.delegate1.id,
             'assignment': self.new_assignment.id}, {'id': self.delegate2.id,
                                                     'assignment': None}
        ]
Пример #6
0
    def test_update_fees(self):
        '''Fees should be calculated when a Registration is created/updated.'''
        b, i, a = 3, 5, 7
        registration = models.new_registration(
            num_beginner_delegates=b,
            num_intermediate_delegates=i,
            num_advanced_delegates=a,
        )

        conference = Conference.get_current()
        delegate_fee = conference.delegate_fee

        self.assertEquals(
            registration.delegate_fees_owed,
            delegate_fee * (b + i + a),
        )

        b2, i2, a2 = 5, 10, 15
        registration.num_beginner_delegates = b2
        registration.num_intermediate_delegates = i2
        registration.num_advanced_delegates = a2
        registration.save()

        self.assertEquals(
            registration.delegate_fees_owed,
            delegate_fee * (b2 + i2 + a2),
        )
Пример #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())
Пример #8
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.chair = models.new_user(
         username='******', password='******', user_type=User.TYPE_CHAIR)
     self.delegate_user = models.new_user(
         username='******',
         password='******',
         user_type=User.TYPE_DELEGATE)
     self.delegate_user_2 = models.new_user(
         username='******',
         password='******',
         user_type=User.TYPE_DELEGATE)
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.rubric = models.new_rubric()
     self.committee = models.new_committee(
         user=self.chair, rubric=self.rubric)
     self.paper = models.new_position_paper()
     self.assignment = models.new_assignment(
         registration=self.registration,
         committee=self.committee,
         paper=self.paper)
     self.delegate = models.new_delegate(
         user=self.delegate_user,
         assignment=self.assignment,
         school=self.school)
Пример #9
0
    def test_update_assignments(self):
        '''It should correctly update the set of country assignments.'''
        cm1 = models.new_committee(name='CM1')
        cm2 = models.new_committee(name='CM2')
        ct1 = models.new_country(name='CT1')
        ct2 = models.new_country(name='CT2')
        ct3 = models.new_country(name='CT3')
        s1 = models.new_school(name='S1')
        r1 = models.new_registration(school=s1)
        s2 = models.new_school(name='S2')
        r2 = models.new_registration(school=s2)

        Assignment.objects.bulk_create([
            Assignment(committee_id=cm.id,
                       country_id=ct.id,
                       registration_id=r1.id) for ct in [ct1, ct2]
            for cm in [cm1, cm2]
        ])

        a = Assignment.objects.get(committee_id=cm2.id, country_id=ct2.id)
        d1 = models.new_delegate(school=s1, assignment=a)
        d2 = models.new_delegate(school=s1, assignment=a)

        # TODO: Also assert on delegate deletion.
        updates = [
            (cm1, ct1, s1, False),
            (cm1, ct2, s1, False),
            (cm1, ct3, s1, False),  # ADDED
            # (cm2, ct1, s1), # DELETED
            (cm2, ct2, s2, False),  # UPDATED
            (cm2, ct3, s2, False),  # ADDED
        ]

        all_assignments = [
            (cm1.id, ct1.id, r1.id, False),
            (cm1.id, ct2.id, r1.id, False),
            (cm1.id, ct3.id, r1.id, False),
            (cm2.id, ct2.id, r2.id, False),
            (cm2.id, ct3.id, r2.id, False),
            (cm2.id, ct1.id, r1.id, False),
        ]

        Assignment.update_assignments(updates)
        assignments = [a[1:-1] for a in Assignment.objects.all().values_list()]
        delegates = Delegate.objects.all()
        self.assertEquals(set(all_assignments), set(assignments))
        self.assertEquals(len(delegates), 2)
Пример #10
0
    def test_update_assignments(self):
        '''It should correctly update the set of country assignments.'''
        cm1 = models.new_committee(name='CM1')
        cm2 = models.new_committee(name='CM2')
        ct1 = models.new_country(name='CT1')
        ct2 = models.new_country(name='CT2')
        ct3 = models.new_country(name='CT3')
        s1 = models.new_school(name='S1')
        r1 = models.new_registration(school=s1)
        s2 = models.new_school(name='S2')
        r2 = models.new_registration(school=s2)

        Assignment.objects.bulk_create([
            Assignment(
                committee_id=cm.id, country_id=ct.id, registration_id=r1.id)
            for ct in [ct1, ct2] for cm in [cm1, cm2]
        ])

        a = Assignment.objects.get(committee_id=cm2.id, country_id=ct2.id)
        d1 = models.new_delegate(school=s1, assignment=a)
        d2 = models.new_delegate(school=s1, assignment=a)

        # TODO: Also assert on delegate deletion.
        updates = [
            (cm1, ct1, s1, False),
            (cm1, ct2, s1, False),
            (cm1, ct3, s1, False),  # ADDED
            # (cm2, ct1, s1), # DELETED
            (cm2, ct2, s2, False),  # UPDATED
            (cm2, ct3, s2, False),  # ADDED
        ]

        all_assignments = [
            (cm1.id, ct1.id, r1.id, False),
            (cm1.id, ct2.id, r1.id, False),
            (cm1.id, ct3.id, r1.id, False),
            (cm2.id, ct2.id, r2.id, False),
            (cm2.id, ct3.id, r2.id, False),
            (cm2.id, ct1.id, r1.id, False),
        ]

        Assignment.update_assignments(updates)
        assignments = [a[1:-1] for a in Assignment.objects.all().values_list()]
        delegates = Delegate.objects.all()
        self.assertEquals(set(all_assignments), set(assignments))
        self.assertEquals(len(delegates), 2)
Пример #11
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.params = {
         'conference': self.registration.conference.session,
         'school': self.registration.school.id,
         'country_preferences': self.registration.country_preference_ids,
         'assignments_finalized': True
     }
Пример #12
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.params = {
         'conference': self.registration.conference.session,
         'school': self.registration.school.id,
         'country_preferences': self.registration.country_preference_ids,
         'assignments_finalized': True,
     }
Пример #13
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.advisor2 = models.new_user(
         username='******', password='******')
     self.chair = models.new_user(
         username='******', password='******', user_type=User.TYPE_CHAIR)
     self.delegate_user = models.new_user(
         username='******',
         password='******',
         user_type=User.TYPE_DELEGATE)
     self.school = models.new_school(user=self.advisor)
     self.school2 = models.new_school(user=self.advisor2)
     self.registration = models.new_registration(school=self.school)
     self.registration2 = models.new_registration(school=self.school2)
     self.committee = models.new_committee(user=self.chair)
     self.assignment = models.new_assignment(
         registration=self.registration, committee=self.committee)
     self.params['assignment'] = self.assignment.id
     self.params['school'] = self.school.id
Пример #14
0
    def test_update_assignment(self):
        '''Tests that when an assignment changes schools, its rejected
           field is set to False and any delegates assigned to it are
           no longer assigned to it.'''
        s1 = models.new_school(name='S1')
        r1 = models.new_registration(school=s1)
        s2 = models.new_school(name='S2')
        r2 = models.new_registration(school=s2)
        a = models.new_assignment(registration=r1, rejected=True)
        d1 = models.new_delegate(school=s1, assignment=a)
        d2 = models.new_delegate(school=s1, assignment=a)
        self.assertEquals(a.delegates.count(), 2)
        self.assertTrue(a.rejected)

        a.registration = r2
        a.save()

        self.assertEquals(a.delegates.count(), 0)
        self.assertEquals(a.rejected, False)
Пример #15
0
    def test_update_assignment(self):
        '''Tests that when an assignment changes schools, its rejected
           field is set to False and any delegates assigned to it are
           no longer assigned to it.'''
        s1 = models.new_school(name='S1')
        r1 = models.new_registration(school=s1)
        s2 = models.new_school(name='S2')
        r2 = models.new_registration(school=s2)
        a = models.new_assignment(registration=r1, rejected=True)
        d1 = models.new_delegate(school=s1, assignment=a)
        d2 = models.new_delegate(school=s1, assignment=a)
        self.assertEquals(a.delegates.count(), 2)
        self.assertTrue(a.rejected)

        a.registration = r2
        a.save()

        self.assertEquals(a.delegates.count(), 0)
        self.assertEquals(a.rejected, False)
Пример #16
0
    def test_update_country_preferences(self):
        '''It should filter and replace the country preferences.'''
        r1 = models.new_registration()
        r2 = models.new_registration()
        c1 = models.new_country().id
        c2 = models.new_country().id
        c3 = models.new_country().id

        country_ids = [0, c1, c2, c2, 0, c3]
        self.assertEquals(0, CountryPreference.objects.all().count())

        r1.update_country_preferences(country_ids)
        self.assertEquals([c1, c2, c3], r1.country_preference_ids)

        r2.update_country_preferences(country_ids)
        self.assertEquals([c1, c2, c3], r2.country_preference_ids)

        r1.update_country_preferences([c3, c1])
        self.assertEquals([c3, c1], r1.country_preference_ids)
        self.assertEquals([c1, c2, c3], r2.country_preference_ids)
Пример #17
0
    def test_update_country_preferences(self):
        '''It should filter and replace the country preferences.'''
        r1 = models.new_registration()
        r2 = models.new_registration()
        c1 = models.new_country().id
        c2 = models.new_country().id
        c3 = models.new_country().id

        country_ids = [0, c1, c2, c2, 0, c3]
        self.assertEquals(0, CountryPreference.objects.all().count())

        r1.update_country_preferences(country_ids)
        self.assertEquals([c1, c2, c3], r1.country_preference_ids)

        r2.update_country_preferences(country_ids)
        self.assertEquals([c1, c2, c3], r2.country_preference_ids)

        r1.update_country_preferences([c3, c1])
        self.assertEquals([c3, c1], r1.country_preference_ids)
        self.assertEquals([c1, c2, c3], r2.country_preference_ids)
Пример #18
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'))
Пример #19
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.assignment = models.new_assignment(registration=self.registration)
     self.delegate = models.new_delegate(
         school=self.school, assignment=self.assignment)
     self.delegate.assignment = None
     self.delegate.save()
     self.superuser = models.new_user(is_superuser=True)
     self.params = {'email': '*****@*****.**'}
     self.assign_params = {'assignment': self.assignment.id}
     self.unassign_params = {'assignment': None}
Пример #20
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])
Пример #21
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.assignment = models.new_assignment(registration=self.registration)
     self.delegate = models.new_delegate(
         school=self.school, assignment=self.assignment)
     self.delegate.assignment = None
     self.delegate.save()
     self.superuser = models.new_user(is_superuser=True)
     self.delegate_user = models.new_user(
         username='******',
         delegate=self.delegate,
         user_type=User.TYPE_DELEGATE)
Пример #22
0
    def test_save(self):
        """
        A delegate's school field and a delegate's assignment's school field
        should be the same if they both exist on the delegate.
        """
        school = models.new_school(name='S1')
        registration = models.new_registration()
        assignment = models.new_assignment(registration=registration)

        self.assertRaises(ValidationError,
                          Delegate.objects.create,
                          name="Test Delegate",
                          school=school,
                          assignment=assignment)
Пример #23
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.chair = models.new_user(
         username='******', password='******', user_type=User.TYPE_CHAIR)
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.committee = models.new_committee(user=self.chair)
     self.country = models.new_country()
     self.delegate_user = models.new_user(
         username='******',
         password='******',
         user_type=User.TYPE_DELEGATE)
     self.params['committee'] = self.committee.id
     self.params['registration'] = self.registration.id
     self.params['country'] = self.country.id
Пример #24
0
    def test_save(self):
        """
        A delegate's school field and a delegate's assignment's school field
        should be the same if they both exist on the delegate.
        """
        school = models.new_school(name='S1')
        registration = models.new_registration()
        assignment = models.new_assignment(registration=registration)

        self.assertRaises(
            ValidationError,
            Delegate.objects.create,
            name="Test Delegate",
            school=school,
            assignment=assignment)
Пример #25
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.params = {
         'conference': self.registration.conference.session,
         'school': self.registration.school.id,
         'country_preferences': self.registration.country_preference_ids,
         'assignments_finalized': True,
         'num_beginner_delegates': 0,
         'num_intermediate_delegates': 0,
         'num_advanced_delegates': 0,
         'num_spanish_speaking_delegates': 0,
         'num_chinese_speaking_delegates': 0,
     }
Пример #26
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.chair = models.new_user(
         username='******', password='******', user_type=User.TYPE_CHAIR)
     self.delegate_user = models.new_user(
         username='******',
         password='******',
         user_type=User.TYPE_DELEGATE)
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.committee = models.new_committee(user=self.chair)
     self.a1 = models.new_assignment(
         registration=self.registration, committee=self.committee)
     self.a2 = models.new_assignment(
         registration=self.registration, committee=self.committee)
     self.a3 = models.new_assignment()
Пример #27
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', 'Email'],
            [
                '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())
Пример #28
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.chair = models.new_user(username='******',
                                  password='******',
                                  user_type=User.TYPE_CHAIR)
     self.delegate_user = models.new_user(username='******',
                                          password='******',
                                          user_type=User.TYPE_DELEGATE)
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.committee = models.new_committee(user=self.chair)
     self.assignment1 = models.new_assignment(
         registration=self.registration, committee=self.committee)
     self.assignment2 = models.new_assignment(
         registration=self.registration)
     self.delegate1 = models.new_delegate(assignment=self.assignment1, )
     self.delegate2 = models.new_delegate(assignment=self.assignment2,
                                          name='Trevor Dowds',
                                          email='*****@*****.**',
                                          summary='Good!')
Пример #29
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.chair = models.new_user(username='******',
                                  password='******',
                                  user_type=User.TYPE_CHAIR)
     self.delegate_user = models.new_user(username='******',
                                          password='******',
                                          user_type=User.TYPE_DELEGATE)
     self.delegate_user_2 = models.new_user(username='******',
                                            password='******',
                                            user_type=User.TYPE_DELEGATE)
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.committee = models.new_committee(user=self.chair)
     self.paper = models.new_position_paper()
     self.assignment = models.new_assignment(registration=self.registration,
                                             committee=self.committee,
                                             paper=self.paper)
     self.delegate = models.new_delegate(user=self.delegate_user,
                                         assignment=self.assignment,
                                         school=self.school)
Пример #30
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.chair = models.new_user(
         username='******', password='******', user_type=User.TYPE_CHAIR)
     self.delegate_user = models.new_user(
         username='******',
         password='******',
         user_type=User.TYPE_DELEGATE)
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
     self.committee = models.new_committee(user=self.chair)
     self.assignment1 = models.new_assignment(
         registration=self.registration, committee=self.committee)
     self.assignment2 = models.new_assignment(
         registration=self.registration)
     self.delegate1 = models.new_delegate(assignment=self.assignment1, )
     self.delegate2 = models.new_delegate(
         assignment=self.assignment2,
         name='Trevor Dowds',
         email='*****@*****.**',
         summary='Good!')
Пример #31
0
    def test_update_fees(self):
        '''Fees should be calculated when a Registration is created/updated.'''
        b, i, a = 3, 5, 7
        registration = models.new_registration(
            num_beginner_delegates=b,
            num_intermediate_delegates=i,
            num_advanced_delegates=a, )

        conference = Conference.get_current()
        delegate_fee = conference.delegate_fee

        self.assertEquals(registration.delegate_fees_owed,
                          delegate_fee * (b + i + a), )

        b2, i2, a2 = 5, 10, 15
        registration.num_beginner_delegates = b2
        registration.num_intermediate_delegates = i2
        registration.num_advanced_delegates = a2
        registration.save()

        self.assertEquals(registration.delegate_fees_owed,
                          delegate_fee * (b2 + i2 + a2), )
Пример #32
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())
Пример #33
0
 def test_advisor(self):
     user = models.new_user()
     school = models.new_school(user=user)
     registration = models.new_registration(school=school)
     a = models.new_assignment(paper=self.object, registration=registration)
     self.as_user(user).do_test(expected_error=auto.EXP_PERMISSION_DENIED)
Пример #34
0
 def setUp(self):
     self.school = models.new_school(name='S1')
     self.registration = models.new_registration()
     self.assignment1 = models.new_assignment(registration=self.registration)
     self.assignment2 = models.new_assignment(registration=self.registration)
Пример #35
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
Пример #36
0
 def get_test_object(cls):
     return models.new_registration()
Пример #37
0
 def setUp(self):
     self.advisor = models.new_user(username='******', password='******')
     self.school = models.new_school(user=self.advisor)
     self.registration = models.new_registration(school=self.school)
Пример #38
0
 def test_advisor(self):
     user = models.new_user()
     school = models.new_school(user=user)
     registration = models.new_registration(school=school)
     a = models.new_assignment(paper=self.object, registration=registration)
     self.as_user(user).do_test(expected_error=auto.EXP_PERMISSION_DENIED)
Пример #39
0
 def get_test_object(cls):
     return models.new_registration()