コード例 #1
0
    def test_superuser(self):
        '''Superusers shouldn't be able to update committees.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.committee.id, params=self.params)
        self.assertMethodNotAllowed(response, 'PATCH')
コード例 #2
0
ファイル: test_delegate.py プロジェクト: hmuntest/huxley
    def test_import(self):
        '''Test that the admin panel can import delegates. '''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        school = TestSchools.new_school()
        cm1 = TestCommittees.new_committee(name='SPD')
        cm2 = TestCommittees.new_committee(name='USS')
        co1 = TestCountries.new_country(name="Côte d'Ivoire")
        co2 = TestCountries.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())
コード例 #3
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_super_user(self):
        '''Countries should not be able to be deleted'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id)
        self.assertMethodNotAllowed(response, 'DELETE')
コード例 #4
0
ファイル: test_country.py プロジェクト: kimeshan/huxley
    def test_superuser(self):
        """Superusers shouldn't be able to update countries."""
        TestUsers.new_superuser(username="******", password="******")
        self.client.login(username="******", password="******")

        response = self.get_response(self.country.id, params=self.params)
        self.assertMethodNotAllowed(response, "PATCH")
コード例 #5
0
ファイル: test_assignment.py プロジェクト: hmuntest/huxley
    def test_import(self):
        '''Test that the admin panel can import Assignments.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        school = TestSchools.new_school()
        cm1 = TestCommittees.new_committee(name='SPD')
        cm2 = TestCommittees.new_committee(name='USS')
        co1 = TestCountries.new_country(name="Côte d'Ivoire")
        co2 = TestCountries.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(
            school=School.objects.get(name='Test School'),
            committee=Committee.objects.get(name='SPD'),
            country=Country.objects.get(name="Côte d'Ivoire")
        ).exists())
        self.assertTrue(Assignment.objects.filter(
            school=School.objects.get(name='Test School'),
            committee=Committee.objects.get(name='USS'),
            country=Country.objects.get(name='Barbara Boxer')
        ).exists())
コード例 #6
0
ファイル: test_school.py プロジェクト: ethanlee16/huxley
    def test_preference_export(self):
        '''Test that the admin panel can properly export school preferences.'''
        TestUsers.new_user(username='******', password='******')
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        school = TestSchools.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",
            "Bilingual?",
            "Specialized/Regional?",
            "Crisis?",
            "Alternative?",
            "Press Corps?",
            "Country 1",
            "Country 2",
            "Country 3",
            "Country 4",
            "Country 5",
            "Country 6",
            "Country 7",
            "Country 8",
            "Country 9",
            "Country 10",
            "Registration Comments"
            ]

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

        countryprefs = [c for c in school.countrypreferences.all()]
        countryprefs += [''] * (10 - len(countryprefs))

        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.prefers_bilingual,
                school.prefers_specialized_regional,
                school.prefers_crisis,
                school.prefers_alternative,
                school.prefers_press_corps]
        fields.extend(countryprefs)
        fields.append(school.registration_comments)

        fields_csv += ",".join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-2])
コード例 #7
0
    def test_superuser(self):
        '''It finalizes the assignments for a superuser.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertFinalized(response)
コード例 #8
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_superuser(self):
        '''Superusers shouldn't be able to update countries.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id, params=self.params)
        self.assertMethodNotAllowed(response, 'PATCH')
コード例 #9
0
    def test_import(self):
        '''Test that the admin panel can import committees.'''
        TestUsers.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())
コード例 #10
0
    def test_superuser(self):
        '''It updates the delegates for a superuser.'''
        TestUsers.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()
            },
        )
コード例 #11
0
ファイル: test_delegate.py プロジェクト: hmuntest/huxley
    def test_superuser(self):
        '''Assignments should not be able to be deleted through API'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.assignment.id)
        self.assert204(response)
コード例 #12
0
    def test_superuser(self):
        '''It finalizes the assignments for a superuser.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.assignment.id)
        self.assertDeleted(response)
コード例 #13
0
ファイル: test_committee.py プロジェクト: hmuntest/huxley
    def test_superuser(self):
        '''Superusers shouldn't be able to create committees.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.params)
        self.assertMethodNotAllowed(response, 'POST')
コード例 #14
0
ファイル: test_country.py プロジェクト: ethanlee16/huxley
    def test_import(self):
        '''Test that the admin panel can import countries. '''
        TestUsers.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())
コード例 #15
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_super_user(self):
        '''Countries should not be able to be deleted'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id)
        self.assertMethodNotAllowed(response, 'DELETE')
コード例 #16
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_super_user(self):
        '''Superusers shouldn't be able to create countries.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.params)
        self.assertMethodNotAllowed(response, 'POST')
コード例 #17
0
ファイル: test_delegate.py プロジェクト: hmuntest/huxley
    def test_superuser(self):
        '''Assignments should not be able to be deleted through API'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.assignment.id)
        self.assert204(response)
コード例 #18
0
    def test_import(self):
        '''Test that the admin panel can import Assignments.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        school = TestSchools.new_school()
        cm1 = TestCommittees.new_committee(name='SPD')
        cm2 = TestCommittees.new_committee(name='USS')
        co1 = TestCountries.new_country(name="Côte d'Ivoire")
        co2 = TestCountries.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(
                school=School.objects.get(name='Test School'),
                committee=Committee.objects.get(name='SPD'),
                country=Country.objects.get(name="Côte d'Ivoire")).exists())
        self.assertTrue(
            Assignment.objects.filter(
                school=School.objects.get(name='Test School'),
                committee=Committee.objects.get(name='USS'),
                country=Country.objects.get(name='Barbara Boxer')).exists())
コード例 #19
0
    def test_superuser(self):
        '''It returns the assignments for a superuser.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assert_assignments_equal(response)
コード例 #20
0
    def test_superuser(self):
        '''It returns the delegates for a superuser.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assert_delegate_equal(response)
コード例 #21
0
ファイル: test_country.py プロジェクト: kimeshan/huxley
    def test_super_user(self):
        """Countries should not be able to be deleted"""
        TestUsers.new_superuser(username="******", password="******")
        self.client.login(username="******", password="******")

        response = self.get_response(self.country.id)
        self.assertMethodNotAllowed(response, "DELETE")
コード例 #22
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_superuser(self):
        '''It should allow a superuser to delete a user.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id)
        self.assertEqual(response.status_code, 204)
        self.assertFalse(User.objects.filter(id=self.user.id).exists())
コード例 #23
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_superuser(self):
        '''It should allow a superuser to delete a user.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id)
        self.assertEqual(response.status_code, 204)
        self.assertFalse(HuxleyUser.objects.filter(id=self.user.id).exists())
コード例 #24
0
    def test_superuser(self):
        '''It should reject a request from a superuser.'''
        TestUsers.new_superuser(username='******', password='******')

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

        self.assertMethodNotAllowed(response, 'GET')
コード例 #25
0
    def test_superuser(self):
        '''It should reject a request from a superuser.'''
        TestUsers.new_superuser(username='******', password='******')

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

        self.assertMethodNotAllowed(response, 'GET')
コード例 #26
0
    def test_superuser(self):
        '''This should allow  a superuser to change school data.'''
        TestUsers.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)
コード例 #27
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_superuser(self):
        '''A superuser should be allowed to change information about a user.'''
        TestUsers.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)
コード例 #28
0
    def test_superuser(self):
        '''This should allow  a superuser to change school data.'''
        TestUsers.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)
コード例 #29
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_superuser(self):
        '''A superuser should be allowed to change information about a user.'''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id, params=self.params)
        user = HuxleyUser.objects.get(id=self.user.id)
        self.assertEqual(response.data['first_name'], user.first_name)
        self.assertEqual(response.data['last_name'], user.last_name)
コード例 #30
0
    def test_superuser(self):
        """Superusers should be able to create assignments."""
        TestUsers.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},
        )
コード例 #31
0
ファイル: test_assignment.py プロジェクト: hmuntest/huxley
    def test_superuser(self):
        '''Superusers should be able to create assignments.'''
        TestUsers.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,
        })
コード例 #32
0
    def test_superuser(self):
        '''Superusers should be able to create assignments.'''
        TestUsers.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,
            })
コード例 #33
0
    def test_superuser(self):
        '''it should allow a get request from a superuser.'''
        school = TestSchools.new_school()
        user = TestUsers.new_superuser(username='******', password='******')

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

        self.assertEqual(
            response.data, {
                'id': school.id,
                'registered': school.registered,
                'name': school.name,
                'address': school.address,
                'city': school.city,
                'state': school.state,
                'zip_code': school.zip_code,
                'country': school.country,
                'primary_name': school.primary_name,
                'primary_email': school.primary_email,
                'primary_phone': school.primary_phone,
                'secondary_name': school.secondary_name,
                'secondary_email': school.secondary_email,
                'secondary_phone': school.secondary_phone,
                'program_type': school.program_type,
                'times_attended': school.times_attended,
                'min_delegation_size': school.min_delegation_size,
                'max_delegation_size': school.max_delegation_size,
                'international': school.international,
                'waitlist': school.waitlist
            })
コード例 #34
0
ファイル: test_school.py プロジェクト: jawoonkim/huxley
    def test_superuser(self):
        '''it should allow a get request from a superuser.'''
        school = TestSchools.new_school()
        user = TestUsers.new_superuser(username='******', password='******')

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

        self.assertEqual(response.data, {
            'id': school.id,
            'registered': school.registered,
            'name': school.name,
            'address': school.address,
            'city': school.city,
            'state': school.state,
            'zip_code': school.zip_code,
            'country': school.country,
            'primary_name': school.primary_name,
            'primary_email': school.primary_email,
            'primary_phone': school.primary_phone,
            'secondary_name': school.secondary_name,
            'secondary_email': school.secondary_email,
            'secondary_phone': school.secondary_phone,
            'program_type': school.program_type,
            'times_attended': school.times_attended,
            'min_delegation_size': school.min_delegation_size,
            'max_delegation_size': school.max_delegation_size,
            'international': school.international,
            'waitlist': school.waitlist})
コード例 #35
0
ファイル: test_school.py プロジェクト: hmuntest/huxley
    def test_superuser(self):
        '''it should allow a get request from a superuser.'''
        school = TestSchools.new_school()
        TestUsers.new_superuser(username='******', password='******')

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

        self.assertEqual(
            response.data, {
                'id': school.id,
                'registered': school.registered.isoformat(),
                'name': school.name,
                'address': school.address,
                'city': school.city,
                'state': school.state,
                'zip_code': school.zip_code,
                'country': school.country,
                'primary_name': school.primary_name,
                'primary_gender': school.primary_gender,
                'primary_email': school.primary_email,
                'primary_phone': school.primary_phone,
                'primary_type': school.primary_type,
                'secondary_name': school.secondary_name,
                'secondary_gender': school.secondary_gender,
                'secondary_email': school.secondary_email,
                'secondary_phone': school.secondary_phone,
                'secondary_type': school.secondary_type,
                'program_type': school.program_type,
                'times_attended': school.times_attended,
                'international': school.international,
                'waitlist': school.waitlist,
                'beginner_delegates': school.beginner_delegates,
                'intermediate_delegates': school.intermediate_delegates,
                'advanced_delegates': school.advanced_delegates,
                'spanish_speaking_delegates':
                school.spanish_speaking_delegates,
                'chinese_speaking_delegates':
                school.chinese_speaking_delegates,
                'countrypreferences': school.country_preference_ids,
                'committeepreferences': list(
                    school.committeepreferences.all()),
                'registration_comments': school.registration_comments,
                'fees_owed': float(school.fees_owed),
                'fees_paid': float(school.fees_paid),
                'assignments_finalized': school.assignments_finalized,
            })
コード例 #36
0
ファイル: test_school.py プロジェクト: ethanlee16/huxley
    def test_superuser(self):
        '''it should allow a get request from a superuser.'''
        school = TestSchools.new_school()
        TestUsers.new_superuser(username='******', password='******')

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

        self.assertEqual(response.data, {
            'id': school.id,
            'registered': school.registered.isoformat(),
            'name': school.name,
            'address': school.address,
            'city': school.city,
            'state': school.state,
            'zip_code': school.zip_code,
            'country': school.country,
            'primary_name': school.primary_name,
            'primary_gender': school.primary_gender,
            'primary_email': school.primary_email,
            'primary_phone': school.primary_phone,
            'primary_type': school.primary_type,
            'secondary_name': school.secondary_name,
            'secondary_gender': school.secondary_gender,
            'secondary_email': school.secondary_email,
            'secondary_phone': school.secondary_phone,
            'secondary_type': school.secondary_type,
            'program_type': school.program_type,
            'times_attended': school.times_attended,
            'international': school.international,
            'waitlist': school.waitlist,
            'beginner_delegates': school.beginner_delegates,
            'intermediate_delegates': school.intermediate_delegates,
            'advanced_delegates': school.advanced_delegates,
            'spanish_speaking_delegates': school.spanish_speaking_delegates,
            'country_preferences': school.country_preference_ids,
            'prefers_bilingual': school.prefers_bilingual,
            'prefers_specialized_regional': school.prefers_specialized_regional,
            'prefers_crisis': school.prefers_crisis,
            'prefers_alternative': school.prefers_alternative,
            'prefers_press_corps': school.prefers_press_corps,
            'registration_comments': school.registration_comments,
            'fees_owed': float(school.fees_owed),
            'fees_paid': float(school.fees_paid),
        })
コード例 #37
0
    def test_preference_export(self):
        '''Test that the admin panel can properly export school preferences.'''
        TestUsers.new_user(username='******', password='******')
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        school = TestSchools.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",
            "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))

        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.append(school.registration_comments)

        fields_csv += ",".join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-2])
コード例 #38
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_superuser(self):
        '''It should allow a superuser to delete a user.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.new_superuser(username='******', password='******')
        url = self.get_url(user1.id)

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

        self.assertEqual(response.status_code, 204)
        self.assertFalse(HuxleyUser.objects.filter(id=user1.id).exists())
コード例 #39
0
ファイル: test_country.py プロジェクト: hmuntest/huxley
    def test_import(self):
        '''Test that the admin panel can import countries. '''
        TestUsers.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())
コード例 #40
0
ファイル: test_assignment.py プロジェクト: hmuntest/huxley
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = TestUsers.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,
     })
コード例 #41
0
ファイル: test_delegate.py プロジェクト: hmuntest/huxley
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = TestUsers.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.delegate.assignment.id,
         "name" : unicode(self.params['name']),
         "email" : unicode(self.params['email']),
         "summary" : unicode(self.params['summary'])}
     )
コード例 #42
0
ファイル: test_delegate.py プロジェクト: hmuntest/huxley
    def test_import(self):
        '''Test that the admin panel can import delegates. '''
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')

        school = TestSchools.new_school()
        cm1 = TestCommittees.new_committee(name='SPD')
        cm2 = TestCommittees.new_committee(name='USS')
        co1 = TestCountries.new_country(name="Côte d'Ivoire")
        co2 = TestCountries.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())
コード例 #43
0
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = TestUsers.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,
         })
コード例 #44
0
ファイル: test_delegate.py プロジェクト: m-j-mcdonald/huxley
 def test_superuser(self):
     '''Should allow superuser to create delegate.'''
     superuser = TestUsers.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']),}
     )
コード例 #45
0
ファイル: test_delegate.py プロジェクト: hmuntest/huxley
 def test_superuser(self):
     '''It should return correct data.'''
     superuser = TestUsers.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.delegate.assignment.id,
             "name": unicode(self.params['name']),
             "email": unicode(self.params['email']),
             "summary": unicode(self.params['summary'])
         })
コード例 #46
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_superuser(self):
        '''It should return the correct fields for a superuser.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.new_superuser(username='******', password='******')
        url = self.get_url(user1.id)

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

        self.assertEqual(len(data.keys()), 6)
        self.assertEqual(data['id'], user1.id)
        self.assertEqual(data['first_name'], user1.first_name)
        self.assertEqual(data['last_name'], user1.last_name)
        self.assertEqual(data['user_type'], HuxleyUser.TYPE_ADVISOR)
        self.assertEqual(data['school'], user1.school_id)
        self.assertEqual(data['committee'], user1.committee_id)
コード例 #47
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_superuser(self):
        '''It should return the correct fields for a superuser.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.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})
コード例 #48
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_superuser(self):
        '''It should return the correct fields for a superuser.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.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})
コード例 #49
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_superuser(self):
        '''It should allow a superuser to list all users.'''
        user1 = TestUsers.new_superuser(username='******', password='******')
        user2 = TestUsers.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},
            {'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}])
コード例 #50
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_superuser(self):
        '''It should allow a superuser to list all users.'''
        user1 = TestUsers.new_superuser(username='******', password='******')
        user2 = TestUsers.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},
            {'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}])
コード例 #51
0
    def test_info_export(self):
        '''Test that the admin panel can properly export a list of schools.'''
        TestUsers.new_user(username='******', password='******')
        TestUsers.new_superuser(username='******', password='******')
        self.client.login(username='******', password='******')
        school = TestSchools.new_school()
        self.client.logout()
        self.client.login(username='******', password='******')

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

        self.assertTrue(response)

        header = [
            "ID",
            "Name",
            "Address",
            "City",
            "State",
            "Zip Code",
            "Country",
            "Primary Name",
            "Primary Gender",
            "Primary Email",
            "Primary Phone",
            "Primary Type",
            "Secondary Name",
            "Secondary Gender",
            "Secondary Email",
            "Secondary Phone",
            "Secondary Type",
            "Program Type",
            "Times Attended",
            "International",
            "Waitlist",
            "Beginners",
            "Intermediates",
            "Advanced",
            "Spanish Speakers",
            "Chinese Speakers",
            "Registration Comments",
            "Fees Owed",
            "Fees Paid",
        ]

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

        fields = [
            school.id,
            school.name,
            school.address,
            school.city,
            school.state,
            school.zip_code,
            school.country,
            school.primary_name,
            school.primary_gender,
            school.primary_email,
            school.primary_phone,
            school.primary_type,
            school.secondary_name,
            school.secondary_gender,
            school.secondary_email,
            school.secondary_phone,
            school.secondary_type,
            school.program_type,
            school.times_attended,
            school.international,
            school.waitlist,
            school.beginner_delegates,
            school.intermediate_delegates,
            school.advanced_delegates,
            school.spanish_speaking_delegates,
            school.chinese_speaking_delegates,
            school.registration_comments,
            school.fees_owed,
            school.fees_paid,
        ]

        fields_csv += ",".join(map(str, fields))
        self.assertEquals(fields_csv, response.content[:-2])
コード例 #52
0
ファイル: test_committee.py プロジェクト: m-j-mcdonald/huxley
 def test_superuser(self):
     '''Superusers cannot delete committees.'''
     TestUsers.new_superuser(username='******', password='******')
     self.do_test(
         username='******', password='******',
         expected_error=auto.EXP_DELETE_NOT_ALLOWED)