コード例 #1
0
ファイル: test_country.py プロジェクト: kimeshan/huxley
    def test_self(self):
        """Authenticated users shouldn't have permission to delete countries."""
        TestUsers.new_user(username="******", password="******")
        self.client.login(username="******", password="******")

        response = self.get_response(self.country.id)
        self.assertMethodNotAllowed(response, "DELETE")
コード例 #2
0
    def test_authenticated_user(self):
        '''Authenticated users shouldn't be able to update committees.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.committee.id, params=self.params)
        self.assertMethodNotAllowed(response, 'PATCH')
コード例 #3
0
    def test_self(self):
        '''Authenticated users shouldn't be able to create countries.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.params)
        self.assertMethodNotAllowed(response, 'POST')
コード例 #4
0
ファイル: test_committee.py プロジェクト: hmuntest/huxley
    def test_self(self):
        '''Authenticated users shouldn't have permission to delete committees.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.committee.id)
        self.assertMethodNotAllowed(response, 'DELETE')
コード例 #5
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])
コード例 #6
0
ファイル: test_country.py プロジェクト: kimeshan/huxley
    def test_authenticated_user(self):
        """Authenticated users shouldn't be able to update countries."""
        TestUsers.new_user(username="******", password="******")
        self.client.login(username="******", password="******")

        response = self.get_response(self.country.id, params=self.params)
        self.assertMethodNotAllowed(response, "PATCH")
コード例 #7
0
ファイル: test_committee.py プロジェクト: hmuntest/huxley
    def test_self(self):
        '''Authenticated users shouldn't have permission to delete committees.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.committee.id)
        self.assertMethodNotAllowed(response, 'DELETE')
コード例 #8
0
ファイル: test_committee.py プロジェクト: hmuntest/huxley
    def test_authenticated_user(self):
        '''Authenticated users shouldn't be able to update committees.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.committee.id, params=self.params)
        self.assertMethodNotAllowed(response, 'PATCH')
コード例 #9
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_self(self):
        '''Authenticated users shouldn't have permission to delete countries.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id)
        self.assertPermissionDenied(response)
コード例 #10
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_anonymous_user(self):
        '''It should reject the request from an anonymous user.'''
        TestUsers.new_user(username='******')
        TestUsers.new_user(username='******')

        response = self.get_response()
        self.assertNotAuthenticated(response)
コード例 #11
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_anonymous_user(self):
        '''It should reject the request from an anonymous user.'''
        TestUsers.new_user(username='******')
        TestUsers.new_user(username='******')

        response = self.get_response()
        self.assertNotAuthenticated(response)
コード例 #12
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_authenticated_user(self):
        '''Authenticated users shouldn't be able to update countries.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id, params=self.params)
        self.assertPermissionDenied(response)
コード例 #13
0
ファイル: test_country.py プロジェクト: ethanlee16/huxley
    def test_self(self):
        '''Authenticated users shouldn't be able to create countries.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.params)
        self.assertMethodNotAllowed(response, 'POST')
コード例 #14
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_authenticated_user(self):
        '''Authenticated users shouldn't be able to update countries.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id, params=self.params)
        self.assertPermissionDenied(response)
コード例 #15
0
ファイル: test_country.py プロジェクト: jawoonkim/huxley
    def test_self(self):
        '''Authenticated users shouldn't have permission to delete countries.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.country.id)
        self.assertPermissionDenied(response)
コード例 #16
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_user(self):
        '''It should reject the request from a regular user.'''
        TestUsers.new_user(username='******', password='******')
        TestUsers.new_user(username='******')
        self.client.login(username='******', password='******')

        response = self.get_response()
        self.assertPermissionDenied(response)
コード例 #17
0
    def test_superuser(self):
        '''A superuser should not be able to delete an account.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')
        response = self.get_response(self.school.id)

        self.assertPermissionDenied(response)
        self.assertTrue(School.objects.filter(id=self.school.id).exists())
コード例 #18
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_other_user(self):
        '''It should reject the request from another user.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id)
        self.assertPermissionDenied(response)
        self.assertTrue(User.objects.filter(id=self.user.id).exists())
コード例 #19
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_user(self):
        '''It should reject the request from a regular user.'''
        TestUsers.new_user(username='******', password='******')
        TestUsers.new_user(username='******')
        self.client.login(username='******', password='******')

        response = self.get_response()
        self.assertPermissionDenied(response)
コード例 #20
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_other_user(self):
        '''It should reject the request from another user.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id)
        self.assertPermissionDenied(response)
        self.assertTrue(HuxleyUser.objects.filter(id=self.user.id).exists())
コード例 #21
0
ファイル: test_school.py プロジェクト: ethanlee16/huxley
    def test_superuser(self):
        '''A superuser should not be able to delete an account.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')
        response = self.get_response(self.school.id)

        self.assertPermissionDenied(response)
        self.assertTrue(School.objects.filter(id=self.school.id).exists())
コード例 #22
0
    def test_other_user(self):
        '''it should not allow a get request from another user.'''
        school = TestSchools.new_school()
        TestUsers.new_user(username='******', password='******')

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

        self.assertPermissionDenied(response)
コード例 #23
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_other_user(self):
        '''It should reject request from another user.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.new_user(username='******', password='******')

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

        self.assertPermissionDenied(response)
コード例 #24
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_other_user(self):
        '''It should reject request from another user.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.new_user(username='******', password='******')

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

        self.assertPermissionDenied(response)
コード例 #25
0
ファイル: test_school.py プロジェクト: ethanlee16/huxley
    def test_other_user(self):
        '''it should not allow a get request from another user.'''
        school = TestSchools.new_school()
        TestUsers.new_user(username='******', password='******')

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

        self.assertPermissionDenied(response)
コード例 #26
0
    def test_other_user(self):
        '''Should not allow another user to change a school's data'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')
        response = self.get_response(self.school.id, params=self.params)
        updated_school = School.objects.get(id=self.school.id)

        self.assertPermissionDenied(response)
        self.assertEqual(updated_school.name, self.school.name)
        self.assertEqual(updated_school.city, self.school.city)
コード例 #27
0
    def test_other_user(self):
        '''Should not allow another user to change a school's data'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')
        response = self.get_response(self.school.id, params=self.params)
        updated_school = School.objects.get(id=self.school.id)

        self.assertPermissionDenied(response)
        self.assertEqual(updated_school.name, self.school.name)
        self.assertEqual(updated_school.city, self.school.city)
コード例 #28
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_other_user(self):
        '''Another user should not be able to change information about any other user.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id, params=self.params)
        self.assertPermissionDenied(response)

        user = HuxleyUser.objects.get(id=self.user.id)
        self.assertEqual(user.first_name, 'Test')
        self.assertEqual(user.last_name, 'User')
コード例 #29
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_other_user(self):
        '''Another user should not be able to change information about any other user.'''
        TestUsers.new_user(username='******', password='******')
        self.client.login(username='******', password='******')

        response = self.get_response(self.user.id, params=self.params)
        self.assertPermissionDenied(response)

        user = User.objects.get(id=self.user.id)
        self.assertEqual(user.first_name, 'Test')
        self.assertEqual(user.last_name, 'User')
コード例 #30
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_other_user(self):
        '''It should reject request from another user.'''
        user1 = TestUsers.new_user(username='******')
        user2 = TestUsers.new_user(username='******', password='******')
        url = self.get_url(user1.id)

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

        self.assertEqual(len(data.keys()), 1)
        self.assertEqual(data['detail'],
                         u'You do not have permission to perform this action.')
コード例 #31
0
ファイル: test_user.py プロジェクト: hmuntest/huxley
    def test_reset_password(self):
        '''It should correctly reset a user's password or raise an error.'''
        password = '******'
        user = TestUsers.new_user(username='******', password=password)
        self.assertTrue(user.check_password(password))

        User.reset_password('lololol')
        user = User.objects.get(id=user.id)
        self.assertFalse(user.check_password(password))

        with self.assertRaises(User.DoesNotExist):
            TestUsers.new_user(username='', email='')
            User.reset_password('')
コード例 #32
0
ファイル: test_user.py プロジェクト: hmuntest/huxley
    def test_reset_password(self):
        '''It should correctly reset a user's password or raise an error.'''
        password = '******'
        user = TestUsers.new_user(username='******', password=password)
        self.assertTrue(user.check_password(password))

        User.reset_password('lololol')
        user = User.objects.get(id=user.id)
        self.assertFalse(user.check_password(password))

        with self.assertRaises(User.DoesNotExist):
            TestUsers.new_user(username='', email='')
            User.reset_password('')
コード例 #33
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_other_user(self):
        '''It should reject the request from another user.'''
        username = '******'
        user1 = TestUsers.new_user(username=username)
        user2 = TestUsers.new_user(username='******', password='******')
        url = self.get_url(user1.id)

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

        self.assertEqual(len(data.keys()), 1)
        self.assertEqual(data['detail'],
                         u'You do not have permission to perform this action.')
        self.assertTrue(HuxleyUser.objects.filter(id=user1.id).exists())
コード例 #34
0
ファイル: test_delegate.py プロジェクト: m-j-mcdonald/huxley
 def test_other_user(self):
     '''A user cannot delete another user's delegates.'''
     joe = TestUsers.new_user(username='******', password='******')
     TestSchools.new_school(user=joe)
     self.do_test(
         username='******', password='******',
         expected_error=auto.EXP_PERMISSION_DENIED)
コード例 #35
0
 def setUp(self):
     self.user = TestUsers.new_user(username='******', password='******')
     self.school = TestSchools.new_school(user=self.user)
     self.country = TestCountries.new_country()
     self.committee1 = TestCommittees.new_committee()
     self.committee2 = TestCommittees.new_committee()
     self.assignment1 = TestAssignments.new_assignment(
         committee=self.committee1,
         country=self.country,
         school=self.school,
     )
     self.assignment2 = TestAssignments.new_assignment(
         committee=self.committee2,
         country=self.country,
         school=self.school,
     )
     self.delegate1 = TestDelegates.new_delegate(
         assignment=self.assignment1,
     )
     self.delegate2 = TestDelegates.new_delegate(
         assignment=self.assignment2,
         name='Trevor Dowds',
         email='*****@*****.**',
         summary='Good!'
     )
コード例 #36
0
    def test_other_user(self):
        '''It rejects a request from another user.'''
        user2 = TestUsers.new_user(username='******', password='******')
        TestSchools.new_school(user=user2)
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertPermissionDenied(response)
コード例 #37
0
 def setUp(self):
     self.user = TestUsers.new_user(username="******", password="******")
     self.school = TestSchools.new_school(user=self.user)
     self.committee = TestCommittees.new_committee()
     self.country = TestCountries.new_country()
     self.params["committee"] = self.committee.id
     self.params["school"] = self.school.id
     self.params["country"] = self.country.id
コード例 #38
0
    def test_other_user(self):
        '''It rejects a request from another user.'''
        user2 = TestUsers.new_user(username='******', password='******')
        TestSchools.new_school(user=user2)
        self.client.login(username='******', password='******')

        response = self.get_response(self.school.id)
        self.assertPermissionDenied(response)
コード例 #39
0
ファイル: test_assignment.py プロジェクト: hmuntest/huxley
 def setUp(self):
     self.user = TestUsers.new_user(username='******', password='******')
     self.school = TestSchools.new_school(user=self.user)
     self.committee = TestCommittees.new_committee()
     self.country = TestCountries.new_country()
     self.params['committee'] = self.committee.id
     self.params['school'] = self.school.id
     self.params['country'] = self.country.id
コード例 #40
0
 def setUp(self):
     self.user = TestUsers.new_user(username='******', password='******')
     self.school = TestSchools.new_school(user=self.user)
     self.committee = TestCommittees.new_committee()
     self.country = TestCountries.new_country()
     self.params['committee'] = self.committee.id
     self.params['school'] = self.school.id
     self.params['country'] = self.country.id
コード例 #41
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_anonymous_user(self):
        '''It should reject request from an anonymous user.'''
        user = TestUsers.new_user()
        url = self.get_url(user.id)
        data = self.get_response(url)

        self.assertEqual(len(data.keys()), 1)
        self.assertEqual(data['detail'],
                         u'Authentication credentials were not provided.')
コード例 #42
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_logout(self):
        user = TestUsers.new_user(username='******', password='******')

        self.client.login(username='******', password='******')
        self.assertEqual(self.client.session['_auth_user_id'], user.id)

        response = self.client.delete(self.url)
        self.assertEqual(response.status_code, 204)
        self.assertTrue('_auth_user_id' not in self.client.session)
コード例 #43
0
ファイル: test_user.py プロジェクト: ctmunwebmaster/huxley
    def test_logout(self):
        user = TestUsers.new_user(username='******', password='******')

        self.client.login(username='******', password='******')
        self.assertEqual(self.client.session['_auth_user_id'], user.id)

        response = self.client.delete(self.url)
        self.assertEqual(response.status_code, 204)
        self.assertTrue('_auth_user_id' not in self.client.session)
コード例 #44
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])
コード例 #45
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_self(self):
        '''It should allow a user to delete themself.'''
        user = TestUsers.new_user(username='******', password='******', school_id=1)
        url = self.get_url(user.id)

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

        self.assertEqual(response.status_code, 204)
        self.assertFalse(HuxleyUser.objects.filter(id=user.id).exists())
コード例 #46
0
ファイル: user.py プロジェクト: mmmccarthy/huxley
    def test_anonymous_user(self):
        '''It should reject the request from an anonymous user.'''
        user = TestUsers.new_user()
        url = self.get_url(user.id)
        data = self.get_data(url)

        self.assertEqual(len(data.keys()), 1)
        self.assertEqual(data['detail'],
                         u'Authentication credentials were not provided.')
        self.assertTrue(HuxleyUser.objects.filter(id=user.id).exists())
コード例 #47
0
 def setUp(self):
     self.user = TestUsers.new_user(username='******', password='******')
     self.school = TestSchools.new_school(user=self.user)
     self.country = TestCountries.new_country()
     self.committee = TestCommittees.new_committee()
     self.assignment = Assignment.objects.create(
         committee=self.committee,
         country=self.country,
         school=self.school,
     )
コード例 #48
0
 def setUp(self):
     self.user = TestUsers.new_user(username='******', password='******')
     self.school = TestSchools.new_school(user=self.user)
     self.country = TestCountries.new_country()
     self.committee = TestCommittees.new_committee()
     self.assignment = Assignment.objects.create(
         committee=self.committee,
         country=self.country,
         school=self.school,
     )
コード例 #49
0
    def test_login(self):
        user = TestUsers.new_user(username='******', password='******')
        user2 = TestUsers.new_user(username='******', password='******')

        credentials = {'username': '******', 'password': '******'}
        response = self.client.post(self.url,
                                    data=json.dumps(credentials),
                                    content_type='application/json')
        self.assertEqual(response.status_code, 201)
        self.assertEqual(self.client.session['_auth_user_id'], user.id)

        credentials = {'username': '******', 'password': '******'}
        response = self.client.post(self.url,
                                    data=json.dumps(credentials),
                                    content_type='application/json')
        self.assertEqual(self.client.session['_auth_user_id'], user.id)

        data = json.loads(response.content)
        self.assertEqual(data['detail'],
                         'Another user is currently logged in.')
コード例 #50
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())
コード例 #51
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_self(self):
        '''It should return the correct fields for a single user.'''
        user = TestUsers.new_user(username='******', password='******', school_id=1)
        self.client.login(username='******', password='******')
        response = self.get_response(user.id)

        self.assertEqual(response.data, {
            'id': user.id,
            'username': user.username,
            'first_name': user.first_name,
            'last_name': user.last_name,
            'user_type': user.user_type,
            'school': user.school_id,
            'committee': user.committee_id})
コード例 #52
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_chair(self):
        '''It should have the correct fields for chairs.'''
        user = TestUsers.new_user(user_type=HuxleyUser.TYPE_CHAIR,
                                  committee_id=4)
        self.client.login(username='******', password='******')
        response = self.get_response(user.id)

        self.assertEqual(response.data, {
            'id': user.id,
            'username': user.username,
            'first_name': user.first_name,
            'last_name': user.last_name,
            'user_type': user.user_type,
            'school': user.school_id,
            'committee': user.committee_id})
コード例 #53
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})
コード例 #54
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_get(self):
        data = self.get_data(self.url)

        self.assertEqual(len(data.keys()), 1)
        self.assertEqual(data['detail'], 'Not found')

        user = TestUsers.new_user(username='******', password='******', school_id=1)
        self.client.login(username='******', password='******')

        data = self.get_data(self.url)
        self.assertEqual(len(data.keys()), 7)
        self.assertEqual(data['id'], user.id)
        self.assertEqual(data['username'], user.username)
        self.assertEqual(data['first_name'], user.first_name)
        self.assertEqual(data['last_name'], user.last_name)
        self.assertEqual(data['user_type'], HuxleyUser.TYPE_ADVISOR)
        self.assertEqual(data['school'], user.school_id)
コード例 #55
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}])
コード例 #56
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
 def setUp(self):
     self.user = TestUsers.new_user(username='******', password='******')
コード例 #57
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])
コード例 #58
0
 def setUp(self):
     self.user = TestUsers.new_user(username='******',
                                    password='******')
コード例 #59
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
    def test_anonymous_user(self):
        '''It should reject request from an anonymous user.'''
        user = TestUsers.new_user()
        response = self.get_response(user.id)

        self.assertNotAuthenticated(response)
コード例 #60
0
ファイル: test_user.py プロジェクト: jawoonkim/huxley
 def test_taken_username(self):
     TestUsers.new_user(username='******', password='******')
     response = self.get_response(params=self.get_params(username='******'))
     self.assertEqual(response.data, {
         'username': ['This username is already taken.']})