当前位置: 首页>>代码示例>>Python>>正文


Python TestSchools.new_school方法代码示例

本文整理汇总了Python中huxley.utils.test.TestSchools.new_school方法的典型用法代码示例。如果您正苦于以下问题:Python TestSchools.new_school方法的具体用法?Python TestSchools.new_school怎么用?Python TestSchools.new_school使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在huxley.utils.test.TestSchools的用法示例。


在下文中一共展示了TestSchools.new_school方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_assignments

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_update_assignments(self):
        '''It should correctly update the set of country assignments.'''
        cm1 = TestCommittees.new_committee(name='CM1').id
        cm2 = TestCommittees.new_committee(name='CM2').id
        ct1 = TestCountries.new_country(name='CT1').id
        ct2 = TestCountries.new_country(name='CT2').id
        ct3 = TestCountries.new_country(name='CT3').id
        s1 = TestSchools.new_school(name='S1').id
        s2 = TestSchools.new_school(name='S2').id

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

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

        Assignment.update_assignments(updates)
        new_assignments = [a[1:] for a in Assignment.objects.all().values_list()]

        self.assertEquals(set(updates), set(new_assignments))
开发者ID:ethanlee16,项目名称:huxley,代码行数:32,代码来源:test_models.py

示例2: test_other_user

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
 def test_other_user(self):
     '''A user cannot delete another user's delegates.'''
     joe = TestUsers.new_user(username='joe', password='schmoe')
     TestSchools.new_school(user=joe)
     self.do_test(
         username='joe', password='schmoe',
         expected_error=auto.EXP_PERMISSION_DENIED)
开发者ID:m-j-mcdonald,项目名称:huxley,代码行数:9,代码来源:test_delegate.py

示例3: test_update_waitlist

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_update_waitlist(self):
        '''New schools should be waitlisted based on the conference settings.'''
        self.assertTrue(hasattr(settings, 'CONFERENCE_WAITLIST_OPEN'))

        with self.settings(CONFERENCE_WAITLIST_OPEN=False):
            s1 = TestSchools.new_school()
            self.assertFalse(s1.waitlist)

        with self.settings(CONFERENCE_WAITLIST_OPEN=True):
            s1.save()
            self.assertFalse(s1.waitlist)
            s2 = TestSchools.new_school()
            self.assertTrue(s2.waitlist)
开发者ID:ethanlee16,项目名称:huxley,代码行数:15,代码来源:test_models.py

示例4: test_superuser

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_superuser(self):
        '''it should allow a get request from a superuser.'''
        school = TestSchools.new_school()
        user = TestUsers.new_superuser(username='user1', password='user1')

        self.client.login(username='user1', password='user1')
        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})
开发者ID:jawoonkim,项目名称:huxley,代码行数:31,代码来源:test_school.py

示例5: test_preference_export

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_preference_export(self):
        '''Test that the admin panel can properly export school preferences.'''
        TestUsers.new_user(username='testuser1', password='test1')
        TestUsers.new_superuser(username='testuser2', password='test2')
        self.client.login(username='testuser1', password='test1')
        school = TestSchools.new_school()
        self.client.logout()
        self.client.login(username='testuser2', password='test2')

        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])
开发者ID:ethanlee16,项目名称:huxley,代码行数:62,代码来源:test_school.py

示例6: test_import

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_import(self):
        '''Test that the admin panel can import Assignments.'''
        TestUsers.new_superuser(username='testuser', password='test')
        self.client.login(username='testuser', password='test')

        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())
开发者ID:hmuntest,项目名称:huxley,代码行数:31,代码来源:test_assignment.py

示例7: test_update_fees

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_update_fees(self):
        '''Fees should be calculated when a School is created/updated.'''
        b, i, a = 3, 5, 7
        school = TestSchools.new_school(
            beginner_delegates=b,
            intermediate_delegates=i,
            advanced_delegates=a,
        )

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

        self.assertEquals(
            school.fees_owed, registration_fee + delegate_fee * (b + i + a),
        )

        b2, i2, a2 = 5, 10, 15
        school.beginner_delegates = b2
        school.intermediate_delegates = i2
        school.advanced_delegates = a2
        school.save()

        self.assertEquals(
            school.fees_owed, registration_fee + delegate_fee * (b2 + i2 + a2),
        )
开发者ID:m-j-mcdonald,项目名称:huxley,代码行数:28,代码来源:test_models.py

示例8: setUp

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
 def setUp(self):
     self.user = TestUsers.new_user(username='user', password='user')
     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
开发者ID:hmuntest,项目名称:huxley,代码行数:10,代码来源:test_assignment.py

示例9: test_anonymous_user

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_anonymous_user(self):
        '''It should reject request from an anonymous user.'''
        school = TestSchools.new_school()
        url = self.get_url(school.id)
        data = self.get_response(url)

        self.assertEqual(len(data.keys()), 1)
        self.assertEqual(data['detail'],
                         u'Authentication credentials were not provided.')
开发者ID:mmmccarthy,项目名称:huxley,代码行数:11,代码来源:school.py

示例10: test_other_user

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_other_user(self):
        '''it should not allow a get request from another user.'''
        school = TestSchools.new_school()
        TestUsers.new_user(username='user2', password='user2')

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

        self.assertPermissionDenied(response)
开发者ID:ethanlee16,项目名称:huxley,代码行数:11,代码来源:test_school.py

示例11: setUp

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
 def setUp(self):
     self.user = TestUsers.new_user(username='regular', password='user')
     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,
     )
开发者ID:hmuntest,项目名称:huxley,代码行数:12,代码来源:test_school_assignments.py

示例12: test_update_country_preferences

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_update_country_preferences(self):
        '''It should filter and replace the school's country preferences.'''
        s1 = TestSchools.new_school()
        s2 = TestSchools.new_school()
        c1 = TestCountries.new_country().id
        c2 = TestCountries.new_country().id
        c3 = TestCountries.new_country().id

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

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

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

        s1.update_country_preferences([c3, c1])
        self.assertEquals([c3, c1], s1.country_preference_ids)
        self.assertEquals([c1, c2, c3], s2.country_preference_ids)
开发者ID:ethanlee16,项目名称:huxley,代码行数:22,代码来源:test_models.py

示例13: test_save

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    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 = TestSchools.new_school(name='S1')
        assignment = TestAssignments.new_assignment()

        self.assertRaises(ValidationError, Delegate.objects.create,
            name="Test Delegate",
            school=school,
            assignment=assignment
        )
开发者ID:m-j-mcdonald,项目名称:huxley,代码行数:15,代码来源:test_models.py

示例14: test_get

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_get(self):
        data = self.get_data(self.url)

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

        school = TestSchools.new_school()
        user = school.advisor
        self.client.login(username=user.username, password='test')

        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'], User.TYPE_ADVISOR)
        self.assertEqual(data['school'], {
            '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,
            'committeepreferences': list(school.committeepreferences.all()),
            'registration_comments': school.registration_comments,
            'fees_owed': float(school.fees_owed),
            'fees_paid': float(school.fees_paid),
        })
开发者ID:ctmunwebmaster,项目名称:huxley,代码行数:52,代码来源:test_user.py

示例15: test_superuser

# 需要导入模块: from huxley.utils.test import TestSchools [as 别名]
# 或者: from huxley.utils.test.TestSchools import new_school [as 别名]
    def test_superuser(self):
        '''it should allow a get request from a superuser.'''
        school = TestSchools.new_school()
        TestUsers.new_superuser(username='user1', password='user1')

        self.client.login(username='user1', password='user1')
        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),
        })
开发者ID:ethanlee16,项目名称:huxley,代码行数:47,代码来源:test_school.py


注:本文中的huxley.utils.test.TestSchools.new_school方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。