コード例 #1
0
 def setUp(self):
     with mock.patch("institution_docs.get_ukrlp_lookups"):
         mock_ukrlp_lookup = json.loads(
             get_string("fixtures/mock_ukrlp_lookup.json"))
         institution_docs.get_ukrlp_lookups.return_value = mock_ukrlp_lookup
         kis_xml_string = get_string("fixtures/large_test_file.xml")
         self.institution_docs = InstitutionDocs(kis_xml_string)
コード例 #2
0
 def test_get_student_unions_one_course(self):
     kis_xml_string = get_string("fixtures/large_test_file.xml")
     inst_xml_string = get_string("fixtures/one_inst_one_course.xml")
     kis_root = ET.fromstring(kis_xml_string)
     locations = Locations(kis_root)
     inst_root = ET.fromstring(inst_xml_string)
     institution = get_first(inst_root.iter("INSTITUTION"))
     get_student_unions(locations, institution)
コード例 #3
0
 def test_get_institution_doc(self):
     xml_string = get_string("fixtures/one_inst_one_course.xml")
     root = ET.fromstring(xml_string)
     institution = get_first(root.iter("INSTITUTION"))
     expected_resp = json.loads(
         get_string("fixtures/one_inst_one_course.json"))
     expected_resp = remove_variable_elements(expected_resp)
     resp = self.institution_docs.get_institution_doc(institution)
     resp = remove_variable_elements(resp)
     self.assertEqual(expected_resp, resp)
コード例 #4
0
 def test_get_student_union_10000047(self):
     kis_xml_string = get_string("fixtures/large_test_file.xml")
     kis_root = ET.fromstring(kis_xml_string)
     locations_lookup = Locations(kis_root)
     institution_pubukprn = "10000047"
     locid = "A1"
     lookup_key = f"{institution_pubukprn}{locid}"
     location = locations_lookup.get_location(lookup_key)
     student_union = get_student_union(location)
     expected_student_union = json.loads(
         get_string("fixtures/su_10000047.json"))
     self.assertEqual(expected_student_union, student_union)
コード例 #5
0
 def test_get_country_scotland(self):
     expected_resp = json.loads(
         get_string("fixtures/country_scotland.json")
     )
     code = "XH"
     resp = get_country(code)
     self.assertEqual(expected_resp, resp)
コード例 #6
0
 def test_get_total_number_of_courses_with_nine_courses(self):
     xml_string = get_string("fixtures/one_inst_nine_courses.xml")
     root = ET.fromstring(xml_string)
     institution = get_first(root.iter("INSTITUTION"))
     expected_number_of_courses = 9
     number_of_courses = get_total_number_of_courses(institution)
     self.assertEqual(expected_number_of_courses, number_of_courses)
コード例 #7
0
    def test_get_student_unions_413_courses(self):

        # Build a locations lookup
        kis_xml_string = get_string("fixtures/large_test_file.xml")
        kis_root = ET.fromstring(kis_xml_string)
        location_lookup = Locations(kis_root)

        # Get an institution so we can pass it to get_student_unions
        institution_xml_string = get_string(
            "fixtures/one_inst_413_courses.xml")
        institution_root = ET.fromstring(institution_xml_string)
        institution = get_first(institution_root.iter("INSTITUTION"))

        student_unions = get_student_unions(location_lookup, institution)
        expected_student_unions = json.loads(
            get_string("fixtures/one_inst_413_courses.json"))
        self.assertEqual(expected_student_unions, student_unions)
コード例 #8
0
 def test_get_location(self):
     kis_xml_string = get_string("fixtures/large_test_file.xml")
     kis_root = ET.fromstring(kis_xml_string)
     locations = Locations(kis_root)
     institution_pubukprn = "10000047"
     locid = "A1"
     lookup_key = f"{institution_pubukprn}{locid}"
     location_data = locations.get_location(lookup_key)
     self.assertEqual(location_data["UKPRN"], "10001143")
     self.assertEqual(location_data["LOCID"], "A1")
     self.assertEqual(location_data["LOCUKPRN"], "10000047")
     self.assertEqual(location_data["LOCCOUNTRY"], "XF")
     self.assertEqual(location_data["SUURL"], "http://ccsu.co.uk/")
コード例 #9
0
    def test_create_institution_docs(
        self,
        mock_get_ukrlp_lookups,
        mock_get_cosmos_client,
        mock_get_collection_link,
        mock_get_institution_doc,
    ):
        kis_xml_string = get_string("fixtures/large_test_file.xml")
        inst_docs = InstitutionDocs(kis_xml_string, 1)

        inst_docs.create_institution_docs()
        mock_get_ukrlp_lookups.assert_called_once()
        mock_get_cosmos_client.assert_called_once()
        mock_get_collection_link.assert_called_once()
        mock_get_institution_doc.assert_called()
コード例 #10
0
 def test_with_large_file(self):
     """Initial smoke test"""
     xml_string = get_string("fixtures/large_test_file.xml")
     root = ET.fromstring(xml_string)
     for institution in root.iter("INSTITUTION"):
         self.institution_docs.get_institution_doc(institution)
コード例 #11
0
 def test_get_country_wales(self):
     expected_resp = json.loads(get_string("fixtures/country_wales.json"))
     code = "XI"
     resp = get_country(code)
     self.assertEqual(expected_resp, resp)