def test_03_different_last_name(self): person_A = person.RosterPerson(last_name='Z', first_name='A', family_relation='Adult', teacher ='', hub_map=common_hub_map) person_B = person.RosterPerson(last_name='Y', first_name='A', family_relation='Adult', teacher ='', hub_map=common_hub_map) self.assertFalse(person_A.IsSame(person_B))
def test_05_different_hub(self): person_A = person.RosterPerson(last_name='Z', first_name='A', family_relation ='Adult', teacher ='First, John', hub_map=common_hub_map) person_B = person.RosterPerson(last_name='Z', first_name='A', family_relation='Adult', teacher ='Second, Jane', hub_map=common_hub_map) self.assertFalse(person_A.IsSame(person_B))
def test_07_same_and_more_hub_child(self): person_A = person.RosterPerson(last_name='Z', first_name='A', family_relation='Child', teacher ='First, John', hub_map=common_hub_map) person_B = person.RosterPerson(last_name='Z', first_name='A', family_relation='Child', teacher ='First, John', hub_map=common_hub_map) person_B.hubs.append('2222') self.assertFalse(person_A.IsSame(person_B))
def test_01_same_person(self): person_A = person.RosterPerson(last_name='A', first_name='B', family_relation ='Adult', teacher ='', hub_map=common_hub_map) self.assertTrue(person_A.IsSame(person_A))
def test_05_unknown_relation(self): result = person.RosterPerson(last_name='A', first_name='B', family_relation =None, teacher ='', hub_map=common_hub_map) self.assertEqual(None, result.last_name) self.assertEqual(None, result.first_name) self.assertEqual(None, result.family_relation) self.assertEqual([] , result.hubs)
def test_04_invalid_child(self): result = person.RosterPerson(last_name='A', first_name=None, family_relation ='Child', teacher ='', hub_map=common_hub_map) self.assertEqual(None, result.last_name) self.assertEqual(None, result.first_name) self.assertEqual(None, result.family_relation) self.assertEqual([] , result.hubs)
def test_01_valid_adult(self): result = person.RosterPerson(last_name ='A', first_name ='B', family_relation ='Adult', teacher ='', hub_map = common_hub_map) self.assertEqual('A' , result.last_name) self.assertEqual('B' , result.first_name) self.assertEqual('Adult', result.family_relation) self.assertEqual([] , result.hubs)
def test_03_null_roster_person(self): test_person = person.RosterPerson(last_name =None, first_name =None, family_relation =None, teacher =None, hub_map ={}) mocker = mock_open() with patch('builtins.open', mocker): with open('testfile', 'w') as open_file: import_file_tools.WriteNewMemberPerson(open_file = open_file, new_person = test_person) handle = mocker() write_calls = [call('None'), call(',None'), call(',None'), call(','), call('\n')] handle.write.assert_has_calls(calls=write_calls, any_order=False)
def AddAdultsFromCombinedField(self, teacher, name_field, hub_map, rosterC): parent_count = 1 parent_num = "" parent_names = name_parser.ParseFullName(name_field, rosterC) for parent in parent_names: new_adult = person.RosterPerson(last_name=parent['last'], first_name=parent['first'], teacher=teacher, family_relation="Adult" + parent_num, hub_map=hub_map) self.adults.append(new_adult) parent_count += 1 parent_num = str(parent_count)
def AddToFamily(self, child_first, child_last, grade, adult_names, teacher_name, hub_map, rosterC): # for elementary school (< 6th grade) teacher name is retained # for middle school, teacher name is replaced with grade level if 0 <= int(grade) <= 5: if hub_map_tools.IsInClassroomHub(hub_map, teacher_name): teacher = teacher_name else: print( "Elementry school student from Roster found with unknown teacher." ) print('Child name:', child_first, child_last, '- Adult name(s):', adult_names, '- Grade and Teacher:', grade, teacher_name) return elif 6 <= int(grade) <= 8: teacher = grade else: print( "Student from Roster found with unknown teacher and unknown grade level." ) print('Child name:', child_first, child_last, '- Adult name(s):', adult_names, '- Grade and Teacher:', grade, teacher_name) return # add adults to the family self.AddAdultsFromCombinedField(teacher=teacher, name_field=adult_names, hub_map=hub_map, rosterC=rosterC) # add the child to the family new_child = person.RosterPerson(last_name=child_last, first_name=child_first, teacher=teacher, family_relation="Child1", hub_map=hub_map) self.children.append(new_child)