예제 #1
0
 def test_set_accreditation_type(self):
     inst = InstitutionFactory()
     inst.set_accreditation_type('Regional')
     self.assertEquals(inst.accreditation_type, 'R')
     inst.set_accreditation_type('National')
     self.assertEquals(inst.accreditation_type, 'N')
     inst.set_accreditation_type('')
     self.assertIsNone(inst.accreditation_type)
예제 #2
0
    def test_update(self):
        i = InstitutionFactory()
        self.assertTrue(i.title.startswith('site'))

        self.fields[0] = str(i.external_id)
        Institution.objects.update_or_create(self.fields)

        i.refresh_from_db()
        self.assertEquals(i.external_id, i.external_id)
        self.assertEquals(i.title, 'Example')
        self.assertEquals(i.website_url, 'https://www.columbia.edu')
        self.assertEquals(i.student_population, 0)
        self.assertTrue(i.private)
        self.assertTrue(i.two_year_program)
        self.assertFalse(i.four_year_program)
        self.assertEquals(i.image, 'https://www.columbia.edu/foo.png')
        self.assertEquals(i.address, 'address')
        self.assertEquals(i.city, 'city')
        self.assertEquals(i.state, 'NY')
        self.assertEquals(i.latlng.coords[0], 40.8075)
        self.assertEquals(i.latlng.coords[1], -73.9626)
        self.assertEquals(i.undergrad_vet_population, 10)
        self.assertEquals(i.undergrad_vet_graduation_rate, 20)
        self.assertEquals(i.grad_vet_population, 30)
        self.assertEquals(i.grad_vet_graduation_rate, 40)
        self.assertEquals(
            i.admissions_url,
            'https://www.columbia.edu',
        )
        self.assertTrue(i.vet_center)
        self.assertFalse(i.sva_chapter)
        self.assertTrue(i.standardized_test_required)
        self.assertEquals(i.standardized_test_notes, 'standardized_test_notes')
        self.assertEquals(i.notes, 'notes')
        self.assertTrue(i.accredited)
        self.assertEquals(i.accreditation_type, 'N')
        self.assertEquals(i.regional_accreditor, None)
        self.assertFalse(i.clep_credits_accepted)
        self.assertFalse(i.jst_credits_accepted)
        self.assertTrue(i.dsst_credits_accepted)
        self.assertTrue(i.yellow_ribbon)
        self.assertEquals(i.yellow_ribbon_slots, '10')
        self.assertEquals(i.yellow_ribbon_contribution, '10000')
        self.assertFalse(i.online_credits_accepted)
        self.assertTrue(i.application_fee_waived)
        self.assertTrue(i.vet_grants_scholarships)
        self.assertEquals(i.vet_grants_scholarships_notes,
                          'vet_grants_scholarships_notes')
예제 #3
0
파일: test_views.py 프로젝트: ccnmtl/ahemap
    def test_filter_public_private(self):
        private_institution = InstitutionFactory(private=True)

        url = '/api/institution/?public=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

        url = '/api/institution/?private=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], private_institution.id)

        url = '/api/institution/?public=true&private=true'
        response = self.client.get(url)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 3)

        url = '/api/institution/?public=false&private=false'
        response = self.client.get(url)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 3)
예제 #4
0
    def test_set_field_value(self):
        i = InstitutionFactory()

        Institution.objects._set_field_value(i, 'set_institution_type',
                                             'Public')
        self.assertFalse(i.private)

        Institution.objects._set_field_value(i, 'set_latitude', '30.000')
        self.assertEquals(i.latlng.coords[0], 30)

        Institution.objects._set_field_value(i, 'set_longitude', '-30.123')
        self.assertEquals(i.latlng.coords[1], -30.123)

        Institution.objects._set_field_value(i, 'set_program_duration',
                                             '2 year, 4 year')
        self.assertTrue(i.two_year_program)
        self.assertTrue(i.four_year_program)

        Institution.objects._set_field_value(i, 'student_population', '10000')
        self.assertEquals(i.student_population, 10000)

        Institution.objects._set_field_value(i, 'student_population', '10,000')
        self.assertEquals(i.student_population, 10000)

        Institution.objects._set_field_value(i, 'city', 'foo')
        self.assertEquals(i.city, 'foo')
예제 #5
0
    def test_find_or_create_by_external_id(self):
        i = InstitutionFactory()
        self.assertEquals(
            i,
            Institution.objects.find_or_create_by_external_id(i.external_id))

        i2 = Institution.objects.find_or_create_by_external_id(123)
        self.assertNotEquals(i, i2)
        self.assertEquals(i2.external_id, 123)
예제 #6
0
    def test_set_program_duration(self):
        inst = InstitutionFactory()

        inst.set_program_duration('')
        self.assertFalse(inst.two_year_program)
        self.assertFalse(inst.four_year_program)

        inst.set_program_duration('4 year')
        self.assertFalse(inst.two_year_program)
        self.assertTrue(inst.four_year_program)

        inst.set_program_duration('2 year, 4 Year')
        self.assertTrue(inst.two_year_program)
        self.assertTrue(inst.four_year_program)
예제 #7
0
파일: test_views.py 프로젝트: ccnmtl/ahemap
    def test_filter_by_population(self):
        small_inst = InstitutionFactory(undergraduate_population=1000)
        url = '/api/institution/?population=small'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], small_inst.id)

        url = '/api/institution/?population=medium'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

        large_inst = InstitutionFactory(undergraduate_population=10001)
        url = '/api/institution/?population=large'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], large_inst.id)
예제 #8
0
파일: test_views.py 프로젝트: ccnmtl/ahemap
 def setUp(self):
     self.inst1 = InstitutionFactory()
     self.inst2 = InstitutionFactory()
예제 #9
0
파일: test_views.py 프로젝트: ccnmtl/ahemap
class InstitutionViewSetTest(TestCase):

    def setUp(self):
        self.inst1 = InstitutionFactory()
        self.inst2 = InstitutionFactory()

    def test_list(self):
        url = '/api/institution/'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

    def test_filter_list(self):
        url = '/api/institution/?q={}'.format(self.inst1.title)
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], self.inst1.id)

    def test_filter_program_duration(self):
        self.inst2.two_year_program = True
        self.inst2.four_year_program = False
        self.inst2.save()

        url = '/api/institution/?twoyear=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], self.inst2.id)

        url = '/api/institution/?fouryear=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], self.inst1.id)

        url = '/api/institution/?twoyear=true&fouryear=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

    def test_filter_yellow_ribbon(self):
        self.inst2.yellow_ribbon = False
        self.inst2.save()

        url = '/api/institution/?yellowribbon=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], self.inst1.id)

        url = '/api/institution/?yellowribbon='
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

    def test_filter_public_private(self):
        private_institution = InstitutionFactory(private=True)

        url = '/api/institution/?public=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

        url = '/api/institution/?private=true'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], private_institution.id)

        url = '/api/institution/?public=true&private=true'
        response = self.client.get(url)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 3)

        url = '/api/institution/?public=false&private=false'
        response = self.client.get(url)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 3)

    def test_filter_by_population(self):
        small_inst = InstitutionFactory(undergraduate_population=1000)
        url = '/api/institution/?population=small'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], small_inst.id)

        url = '/api/institution/?population=medium'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

        large_inst = InstitutionFactory(undergraduate_population=10001)
        url = '/api/institution/?population=large'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 1)
        self.assertEquals(the_json[0]['id'], large_inst.id)

    def test_filter_state(self):
        url = '/api/institution/?state=NJ'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 0)

        url = '/api/institution/?state=NY'
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(len(the_json), 2)
        self.assertEquals(the_json[0]['id'], self.inst1.id)
        self.assertEquals(the_json[1]['id'], self.inst2.id)

    def test_get(self):
        url = '/api/institution/{}/'.format(self.inst1.id)
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        the_json = loads(response.content.decode('utf-8'))
        self.assertEquals(the_json['id'], self.inst1.id)

    def test_post(self):
        url = '/api/institution/{}/'.format(self.inst1.id)
        response = self.client.post(url, {'id': self.inst1.id, 'title': 'foo'})
        self.assertEquals(response.status_code, 403)

    def test_put(self):
        url = '/api/institution/{}/'.format(self.inst1.id)
        response = self.client.put(url, {'id': self.inst1.id, 'title': 'foo'})
        self.assertEquals(response.status_code, 403)
예제 #10
0
 def test_factory(self):
     inst = InstitutionFactory()
     self.assertIsNotNone(inst.latlng)