How to add extension to Test Database in django?

74 Views Asked by At

I'm using TrigramSimilarity in my project. but when i want to test my view in a testcase it seems that the test database doesn't have the extention. how do i add the extention in test database?

def test_person_search(self):
    query = str(self.person.name)

    url = reverse("persons:person_search") + f"?q={query}"

    test_data = {
        "query": query,
        "results": [
            {
                "name": "TestPerson",
                "picture": None,
                "roles": [{"role": "Test", "slug": "test"}],
            }
        ],
    }

    response = self.client.get(url)
    
    self.assertEqual(response.status_code, status.HTTP_200_OK)
    self.assertEqual(response.data, test_data)

Error:

django.db.utils.ProgrammingError: function similarity(character varying, unknown) does not exist
LINE 1: ...."height_centimeter", "persons_person"."picture", SIMILARITY...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
0

There are 0 best solutions below