def test_link_to_event_valid_instructor_name(self, event): #ARRANGE studio_1 = Studio() studio_1.save() studio_2 = Studio() studio_2.save() instructor = Instructor() instructor.aliases_list = list([ 'Aimee McCabe - Karr', ]) instructor.name_url = 'test_link_to_event_valid_instructor_name2' instructor.save() instructor.studios.add(studio_1) event.instructor_name = ' Teacher_AMK ' event.studio = studio_2 #ACT instructor.link_to_event(event) new_aliases_list = instructor.aliases_list new_studio_list = instructor.studios #ASSERT self.assertIsNotNone(new_aliases_list) self.assertEqual(len(new_aliases_list), 2) self.assertIn('Teacher_AMK', new_aliases_list) self.assertIsNotNone(new_studio_list) self.assertEqual(new_studio_list.count(), 2)
def test_link_to_event_invalid_instructor_name(self, event): #ARRANGE instructor = Instructor() instructor.aliases_list = list([ 'Aimee McCabe - Karr', ]) event.instructor_name = ' TBA ' #ACT instructor.link_to_event(event) new_aliases_list = instructor.aliases_list #ASSERT self.assertIsNotNone(instructor) self.assertEqual(len(new_aliases_list), 1) self.assertIn('Aimee McCabe - Karr', new_aliases_list)
def test_saving_alias_as_list(self): #ARRANGE list_of_aliases = list(["value1", "value2"]) #ACT newObj = Instructor() newObj.name_url = "test_saving_alias_as_list" newObj.aliases_list = list_of_aliases newObj.save() id = newObj.id #ASSERT self.assertIsNotNone(id) #ACT 2 fetchObj = Instructor.objects.get(pk=id) #ASSERT 2 self.assertIsNotNone(fetchObj) self.assertListEqual(fetchObj.aliases_list, list_of_aliases)