def test_get_stats_with_subj(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_tariff_with_subj.xml"))["KISCOURSE"] expected_result = json.loads( get_string("fixtures/tariff_get_stats_resp_with_subj.json")) json_obj = self.tariff.get_stats(raw_course_xml) self.assertListEqual(json_obj, expected_result)
def test_get_stats_with_subj(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_with_subj_for_most.xml"))["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_emp_subj_resp.json")) json_obj = self.employment.get_stats(raw_course_xml) self.assertListEqual(json_obj, expected_response)
def test_salary_get_stats_with_subj(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_sal_subj.xml"))["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_sal_subj_resp.json")) json_obj = self.salary.get_stats(raw_course_xml) self.assertListEqual(json_obj, expected_response)
def test_get_stats_no_subj(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_nhs_no_subj.xml"))["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_nhs_no_subj_resp.json")) json_obj = self.nhs.get_stats(raw_course_xml) self.assertDictEqual(json_obj[0], expected_response[0])
def test_specific_10000047_with_new_crsecsturl_field(self): xml_string = get_string("fixtures/large-test-file.xml") root = ET.fromstring(xml_string) accreditations = Accreditations(root) kisaims = KisAims(root) locations = Locations(root) xml_string = get_string( "fixtures/one_inst_one_course_with_crsecsturl.xml") root = ET.fromstring(xml_string) institution = get_first(root.iter("INSTITUTION")) raw_inst_data = xmltodict.parse( ET.tostring(institution))["INSTITUTION"] ukprn = raw_inst_data["UKPRN"] course = get_first(institution.findall("KISCOURSE")) raw_course_data = xmltodict.parse(ET.tostring(course))["KISCOURSE"] locids = get_locids(raw_course_data, ukprn) expected_course_doc = json.loads( get_string("fixtures/one_inst_one_course_with_crsecsturl.json")) course_doc = get_course_doc( accreditations, locations, locids, raw_inst_data, raw_course_data, kisaims, ) course_doc = remove_variable_elements(course_doc) self.assertEqual(expected_course_doc, course_doc)
def test_get_stats_subj(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_with_subj_for_most.xml"))["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_cont_subj_resp.json")) continuation = self.continuation.get_stats(raw_course_xml) self.assertListEqual(continuation, expected_response)
def test_no_subj(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_no_subj_for_most.xml"))["KISCOURSE"] expected_result = json.loads( get_string("fixtures/course_no_com_subj_resp.json")) json_obj = self.job_list.get_stats(raw_course_xml) self.assertListEqual(json_obj, expected_result)
def test_get_stats_agg_14(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_532986.xml"))["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_532986_resp.json")) continuation = self.continuation.get_stats(raw_course_xml) self.assertListEqual(continuation, expected_response)
def test_get_stats_no_data(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_leo_no_data.xml"))["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_leo_no_data_resp.json")) country_code = "XF" leo = Leo(country_code) json_obj = leo.get_stats(raw_course_xml) self.assertEqual(json_obj[0], expected_response[0])
def test_three_commons(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_three_commons.xml") )["KISCOURSE"] json_obj = self.job_list.get_stats(raw_course_xml) expected_result = json.loads( get_string("fixtures/course_three_commons.json") ) self.assertListEqual(json_obj, expected_result)
def test_get_tariffs_list(self): raw_course_xml = xmltodict.parse( get_string("fixtures/course_tariff_with_subj.xml"))["KISCOURSE"] raw_xml_list = SharedUtils.get_raw_list(raw_course_xml, "TARIFF") tariff_xml_elem = raw_xml_list[0] tariff_list = self.tariff.get_tariffs_list(tariff_xml_elem) expected_result = json.loads( get_string("fixtures/tariff_get_tariffs_list_resp.json")) self.assertListEqual(tariff_list, expected_result)
def test_get_multiple_accreditations(self): raw_course_xml = xmltodict.parse( get_string( "fixtures/course_with_accreditations.xml"))["KIS"]["KISCOURSE"] expected_response = json.loads( get_string("fixtures/course_accreditation_resp.json")) accreditations = get_accreditations(raw_course_xml, self.accreditations) self.assertListEqual(accreditations, expected_response)
def test_get_leo3_inst_no_data(self): element = "LEO3" raw_course_xml = xmltodict.parse( get_string( "fixtures/course_leo3_inst_no_data.xml"))["KISCOURSE"][element] expected_response = json.loads( get_string("fixtures/course_leo3_inst_no_data_resp.json")) json_obj = get_leo3_inst_json(raw_course_xml) self.assertEqual(json_obj[0], expected_response[0])
def test_get_govoicework_no_data(self): element = "GOVOICEWORK" raw_course_xml = xmltodict.parse( get_string("fixtures/course_govoicework_no_data.xml") )["KISCOURSE"][element] expected_response = json.loads( get_string("fixtures/course_govoicework_no_data_resp.json") ) json_obj = get_go_voice_work_json(raw_course_xml) self.assertEqual(json_obj[0], expected_response[0])
def test_get_multiple_locations(self): raw_course_xml = xmltodict.parse( get_string( "fixtures/course_with_locations.xml"))["KIS"]["KISCOURSE"] pub_ukprn = "10007814" locids = get_locids(raw_course_xml, pub_ukprn) expected_response = json.loads( get_string("fixtures/course_location_resp.json")) locations = get_location_items(self.locations, locids, raw_course_xml, pub_ukprn) self.assertListEqual(locations, expected_response)
def test_need_nhs_nss_one_inst_one_course(self): xml_string = get_string("fixtures/one_inst_one_course.xml") root = ET.fromstring(xml_string) institution = get_first(root.iter("INSTITUTION")) course = get_first(institution.findall("KISCOURSE")) raw_course_data = xmltodict.parse(ET.tostring(course))["KISCOURSE"] self.assertFalse(need_nhs_nss(raw_course_data))
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"): for course in institution.findall("KISCOURSE"): raw_course_data = xmltodict.parse( ET.tostring(course))["KISCOURSE"] self.continuation.get_stats(raw_course_data)
def test_with_large_file(self): xml_string = get_string("fixtures/large-test-file.xml") root = ET.fromstring(xml_string) for institution in root.iter("INSTITUTION"): raw_inst_data = xmltodict.parse( ET.tostring(institution))["INSTITUTION"] for course in institution.findall("KISCOURSE"): raw_course_data = xmltodict.parse( ET.tostring(course))["KISCOURSE"] need_nhs_nss(raw_course_data)
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"): raw_inst_data = xmltodict.parse( ET.tostring(institution))["INSTITUTION"] country_code = get_country(raw_inst_data)["code"] for course in institution.findall("KISCOURSE"): raw_course_data = xmltodict.parse( ET.tostring(course))["KISCOURSE"] leo = Leo(country_code) leo.get_stats(raw_course_data)
def test_with_large_file(self): xml_string = get_string("fixtures/large-test-file.xml") root = ET.fromstring(xml_string) accreditations = Accreditations(root) kisaims = KisAims(root) locations = Locations(root) for institution in root.iter("INSTITUTION"): raw_inst_data = xmltodict.parse( ET.tostring(institution))["INSTITUTION"] ukprn = raw_inst_data["UKPRN"] for course in institution.findall("KISCOURSE"): raw_course_data = xmltodict.parse( ET.tostring(course))["KISCOURSE"] locids = get_locids(raw_course_data, ukprn) course_doc = get_course_doc( accreditations, locations, locids, raw_inst_data, raw_course_data, kisaims, ) self.assertTrue("institution_id" in course_doc)
def test_need_nhs_nss_with_nhs_nss(self): course_xml = xmltodict.parse( get_string("fixtures/course_nhs_subj.xml"))["KISCOURSE"] self.assertTrue(need_nhs_nss(course_xml))
def setUp(self): xml_string = get_string("fixtures/course_with_accreditations.xml") root = ET.fromstring(xml_string) self.accreditations = Accreditations(root)
def setUp(self): xml_string = get_string("fixtures/course_with_locations.xml") root = ET.fromstring(xml_string) self.locations = Locations(root)