Skip to content

Instantly share code, notes, and snippets.

View harshvb7's full-sized avatar

Harsh harshvb7

  • Cologne, Germany
View GitHub Profile
# we also index a keyword version of the field
name = Text(
analyzer=my_custom_analyzer,
fields={'keyword': es.Keyword()}
)
# and use it with facets like this
'city': TermsFacet(field='user.city.name.keyword'),
tests/views/test_project_detail_view.py
tests/views/.....
>> Views must ONLY test input and status code of the response. Mock the business logic to test the status code.
Ideally our views should be very SLIM and all the logic must go in services and helper functions
If we need to access some variables from request in the service, then better destructure it in the view and pass ONLY the variable in the service NEVER the request object.
In case of API view, call the service from the serializer after validating the input. Don't come back to the view with the validated input and then put the input again in the service.
tests/services/test_document_service.py