Exemple #1
0
    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)
Exemple #2
0
    def test_query_db_by_alias_case_insensitive(self):
        #ARRANGE
        aliases = " ValuE1 ; value2 "
        instructor_name = 'value1'

        #ACT
        newObj = Instructor()
        newObj.name_url = "test_query_db_by_alias_case_insensitive"
        newObj.aliases = aliases
        newObj.save()

        instructors = Instructor.objects.all().filter(
            aliases__icontains=instructor_name)

        #ASSERT
        self.assertIsNotNone(instructors)
        self.assertEqual(len(instructors), 1)
        self.assertEqual(instructors[0].id, newObj.id)
Exemple #3
0
    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)