File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
src/django_elasticsearch_dsl_drf/tests Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 1717 'search_indexes.documents.address' : 'test_address' ,
1818 'search_indexes.documents.author' : 'test_author' ,
1919 'search_indexes.documents.book' : 'test_book' ,
20+ 'search_indexes.documents.tag' : 'test_tag' ,
2021 'search_indexes.documents.city' : 'test_city' ,
2122 'search_indexes.documents.publisher' : 'test_publisher' ,
2223 'search_indexes.documents.location' : 'test_location' ,
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class TestViews(BaseRestFrameworkTestCase):
4242 def setUpClass (cls ):
4343 """Set up class."""
4444 cls .books = factories .BookWithoutTagsAndOrdersFactory .create_batch (20 )
45+ cls .tags = factories .TagGenreFactory .create_batch (20 )
4546
4647 call_command ('search_index' , '--rebuild' , '-f' )
4748
@@ -70,6 +71,16 @@ def test_detail_view(self):
7071 getattr (__obj , __field )
7172 )
7273
74+ def test_detail_view_with_custom_lookup (self ):
75+ """Test detail view with a custom lookup field."""
76+ __obj = self .tags [0 ]
77+ url = reverse ('tagdocument-detail' , kwargs = {'title' : __obj .title })
78+ data = {}
79+
80+ response = self .client .get (url , data )
81+ self .assertEqual (response .status_code , status .HTTP_200_OK )
82+ self .assertEqual (response .data ['id' ], __obj .title )
83+
7384
7485if __name__ == '__main__' :
7586 unittest .main ()
You can’t perform that action at this time.
0 commit comments