Exemple #1
0
 def _load_student_demographics_map(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['demographics'])
     self.gender_map = ValueMapBuilder.build_value_map(raw_data, 'email', 'gender')
     self.first_gen_map = ValueMapBuilder.build_value_map(raw_data, 'email', 'is_first_gen')
     self.pell_map = ValueMapBuilder.build_value_map(raw_data, 'email', 'is_pell_eligible')
     self.urm_map = ValueMapBuilder.build_value_map(raw_data, 'email', 'is_urm')
     self.visa_map = ValueMapBuilder.build_value_map(raw_data, 'email', 'visa_status')
Exemple #2
0
 def _load_cont_ed_maps(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['cont_ed'])
     self.college_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'clean_college')
     self.major_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'clean_major')
     self.degree_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'degree')
     self.major_group_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'major_group')
Exemple #3
0
 def test_build_multi_degree_mapping(self):
     mapping_data = [{
         'email': '*****@*****.**',
         'degree': 'B.S.',
         'major': 'Computer Science',
         'college': 'Whiting School of Engineering'
     }, {
         'email': '*****@*****.**',
         'degree': 'B.S.',
         'major': 'Mech Eng',
         'college': 'Whiting School of Engineering'
     }, {
         'email': '*****@*****.**',
         'degree': 'B.A.',
         'major': 'English',
         'college': 'Krieger School of Arts and Sciences'
     }]
     expected = ValueMap()
     expected.add_mapping('*****@*****.**', [
         JHUDegree(degree='B.S.',
                   major='Computer Science',
                   college='Whiting School of Engineering'),
         JHUDegree(degree='B.S.',
                   major='Mech Eng',
                   college='Whiting School of Engineering'),
         JHUDegree(degree='B.A.',
                   major='English',
                   college='Krieger School of Arts and Sciences')
     ])
     self.assertEqual(expected,
                      ValueMapBuilder.build_jhu_degree_map(mapping_data))
 def test_build_mapping_for_multiple_locations(self):
     test_input = [{
         'raw_location': 'Folsom',
         'city': 'Folsom',
         'state': 'California',
         'country': 'United States'
     }, {
         'raw_location': 'New York, New York',
         'city': 'New York City',
         'state': 'New York',
         'country': 'United States'
     }, {
         'raw_location': 'Beijing, China',
         'city': 'Beijing',
         'state': '',
         'country': 'China'
     }]
     location_map = ValueMapBuilder.build_cached_location_map(
         test_input, 'raw_location')
     self.assert_mapping_is(
         Location('Folsom', 'California', 'United States'),
         Location('Folsom'), location_map)
     self.assert_mapping_is(
         Location('New York City', 'New York', 'United States'),
         Location('New York, New York'), location_map)
     self.assert_mapping_is(Location('Beijing', None, 'China'),
                            Location('Beijing', 'China'), location_map)
 def test_build_mapping_for_empty_location(self):
     test_input = [{
         'raw_location': '$8jg$gjfi',
         'city': '',
         'state': '',
         'country': ''
     }]
     location_map = ValueMapBuilder.build_cached_location_map(
         test_input, 'raw_location')
     self.assert_mapping_is(Location(), Location('$8jg$gjfi'), location_map)
 def test_build_multi_field_value_map(self):
     value_map = ValueMapBuilder.build_multi_field_value_map(
         [{
             'first_field': 'value1',
             'second_field': 'value2',
             'third_field': 'value3'
         }], 'first_field', {'second_field', 'third_field'})
     self.assertEqual({
         'second_field': 'value2',
         'third_field': 'value3'
     }, value_map.get_mapping('value1'))
Exemple #7
0
 def test_build_multi_student_mapping(self):
     mapping_data = [{
         'email': '*****@*****.**',
         'degree': 'B.A.',
         'major': 'Mathematics',
         'college': 'Krieger School of Arts and Sciences'
     }, {
         'email': '*****@*****.**',
         'degree': 'B.S.',
         'major': 'Mech Eng',
         'college': 'Whiting School of Engineering'
     }, {
         'email': '*****@*****.**',
         'degree': 'B.A.',
         'major': 'English',
         'college': 'Krieger School of Arts and Sciences'
     }, {
         'email': '*****@*****.**',
         'degree': 'B.S.',
         'major': 'Electrical Engineering',
         'college': 'Whiting School of Engineering'
     }, {
         'email': '*****@*****.**',
         'degree': 'B.A.',
         'major': 'Writing Seminars',
         'college': 'Krieger School of Arts and Sciences'
     }]
     expected = ValueMap()
     expected.add_mapping('*****@*****.**', [
         JHUDegree(degree='B.A.',
                   major='Mathematics',
                   college='Krieger School of Arts and Sciences')
     ])
     expected.add_mapping('*****@*****.**', [
         JHUDegree(degree='B.S.',
                   major='Mech Eng',
                   college='Whiting School of Engineering'),
         JHUDegree(degree='B.A.',
                   major='English',
                   college='Krieger School of Arts and Sciences')
     ])
     expected.add_mapping('*****@*****.**', [
         JHUDegree(degree='B.S.',
                   major='Electrical Engineering',
                   college='Whiting School of Engineering'),
         JHUDegree(degree='B.A.',
                   major='Writing Seminars',
                   college='Krieger School of Arts and Sciences')
     ])
     self.assertEqual(expected,
                      ValueMapBuilder.build_jhu_degree_map(mapping_data))
 def test_build_multiple_value_mapping(self):
     value_map = ValueMapBuilder.build_cached_value_map([{
         'unclean': 'Valv',
         'clean': 'Valve'
     }, {
         'unclean': 'deLOIte',
         'clean': 'Deloitte'
     }, {
         'unclean': 'Goggle',
         'clean': 'Google'
     }], 'unclean', 'clean')
     self.assertEqual('Valve', value_map.get_mapping('Valv'))
     self.assertEqual('Deloitte', value_map.get_mapping('deLOIte'))
     self.assertEqual('Google', value_map.get_mapping('Goggle'))
Exemple #9
0
 def _load_employer_name_map(self):
     raw_data = csv_to_list_of_dicts(
         self._mapping_filepaths['employer_name'])
     self.employer_name_map = ValueMapBuilder.build_cached_value_map(
         raw_data, 'old_value', 'new_value')
Exemple #10
0
 def _load_fellowship_recoding_map(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['fellowship'])
     self.fellowship_recoding_map = ValueMapBuilder.build_multi_field_value_map(
         raw_data, 'email', {'fellowship_org', 'fellowship_name'})
Exemple #11
0
 def _load_outcome_map(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['outcome'])
     self.outcome_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'outcome')
Exemple #12
0
 def _load_salary_map(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['salary'])
     self.salary_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'salary')
Exemple #13
0
 def _load_jhu_degree_map(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['jhu_degree'])
     self.jhu_degree_map = ValueMapBuilder.build_jhu_degree_map(raw_data)
Exemple #14
0
 def _load_job_function_map(self):
     raw_data = csv_to_list_of_dicts(
         self._mapping_filepaths['job_function'])
     self.job_function_map = ValueMapBuilder.build_value_map(
         raw_data, 'email', 'job_function')
 def test_build_single_value_mapping(self):
     value_map = ValueMapBuilder.build_value_map([{
         'first_field': 'value1',
         'second_field': 'value2'
     }], 'first_field', 'second_field')
     self.assertEqual('value2', value_map.get_mapping('value1'))
Exemple #16
0
 def _load_missing_locations_map(self):
     raw_data = csv_to_list_of_dicts(
         self._mapping_filepaths['missing_locations'])
     self.missing_locations_map = ValueMapBuilder.build_location_map(
         raw_data, 'email')
Exemple #17
0
 def _load_location_map(self):
     raw_data = csv_to_list_of_dicts(self._mapping_filepaths['location'])
     self.location_map = ValueMapBuilder.build_cached_location_map(
         raw_data, 'raw_location')
 def test_build_empty_value_map(self):
     self.assertEqual(
         ValueMap(),
         ValueMapBuilder.build_value_map([], 'from_field', 'to_field'))
Exemple #19
0
 def test_build_empty_map(self):
     self.assertEqual(ValueMap(), ValueMapBuilder.build_jhu_degree_map([]))
Exemple #20
0
 def _load_employer_industry_map(self):
     raw_data = csv_to_list_of_dicts(
         self._mapping_filepaths['employer_industry'])
     self.employer_industry_map = ValueMapBuilder.build_cached_value_map(
         raw_data, 'employer', 'industry')