Exemple #1
0
    def test_alias_list_field_is_white_space(self):
        #ARRANGE
        instructor = Instructor()
        instructor.aliases = '  '

        #ACT
        new_aliases_list = instructor.aliases_list

        #ASSERT
        self.assertIsNotNone(new_aliases_list)
        self.assertEqual(len(new_aliases_list), 0)
Exemple #2
0
    def test_add_alias_empty_alias(self):
        #ARRANGE
        instructor = Instructor()
        instructor.aliases = ''
        new_alias = ' Instructor_A '

        #ACT
        instructor.add_alias(new_alias)
        new_aliases_list = instructor.aliases_list

        #ASSERT
        self.assertIsNotNone(new_aliases_list)
        self.assertEqual(len(new_aliases_list), 1)
        self.assertIn('Instructor_A', new_aliases_list)
Exemple #3
0
    def test_add_alias_duplicate_alias(self):
        #ARRANGE
        instructor = Instructor()
        instructor.aliases = 'Aimee McCabe - Karr; Teacher 1; Instructor_A'
        new_alias = ' instructor_a '

        #ACT
        instructor.add_alias(new_alias)
        new_aliases_list = instructor.aliases_list

        #ASSERT
        self.assertIsNotNone(new_aliases_list)
        self.assertEqual(len(new_aliases_list), 3)
        self.assertIn('Aimee McCabe - Karr', new_aliases_list)
        self.assertIn('Teacher 1', new_aliases_list)
        self.assertIn('Instructor_A', new_aliases_list)
Exemple #4
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)