11import json
22
3- from django .core import signing
43from django .utils .encoding import smart_str
54
65from django_select2 .cache import cache
@@ -21,7 +20,7 @@ def test_get(self, client, artists):
2120 artist = artists [0 ]
2221 form = AlbumModelSelect2WidgetForm ()
2322 assert form .as_p ()
24- field_id = signing . dumps ( id ( form .fields ['artist' ].widget ))
23+ field_id = form .fields ['artist' ].widget . widget_id
2524 url = reverse ('django_select2:auto-json' )
2625 response = client .get (url , {'field_id' : field_id , 'term' : artist .title })
2726 assert response .status_code == 200
@@ -43,7 +42,7 @@ def test_wrong_field_id(self, client, artists):
4342
4443 def test_field_id_not_found (self , client , artists ):
4544 artist = artists [0 ]
46- field_id = signing . dumps ( 123456789 )
45+ field_id = 'not-exists'
4746 url = reverse ('django_select2:auto-json' )
4847 response = client .get (url , {'field_id' : field_id , 'term' : artist .title })
4948 assert response .status_code == 404
@@ -56,7 +55,7 @@ def test_pagination(self, genres, client):
5655 search_fields = ['title__icontains' ]
5756 )
5857 widget .render ('name' , None )
59- field_id = signing . dumps ( id ( widget ))
58+ field_id = widget . widget_id
6059
6160 response = client .get (url , {'field_id' : field_id , 'term' : '' })
6261 assert response .status_code == 200
@@ -77,7 +76,7 @@ def test_label_from_instance(self, artists, client):
7776 form = AlbumModelSelect2WidgetForm ()
7877 form .fields ['artist' ].widget = ArtistCustomTitleWidget ()
7978 assert form .as_p ()
80- field_id = signing . dumps ( id ( form .fields ['artist' ].widget ))
79+ field_id = form .fields ['artist' ].widget . widget_id
8180
8281 artist = artists [0 ]
8382 response = client .get (url , {'field_id' : field_id , 'term' : artist .title })
@@ -91,7 +90,7 @@ def test_url_check(self, client, artists):
9190 artist = artists [0 ]
9291 form = AlbumModelSelect2WidgetForm ()
9392 assert form .as_p ()
94- field_id = signing . dumps ( id ( form .fields ['artist' ].widget ))
93+ field_id = form .fields ['artist' ].widget . widget_id
9594 cache_key = form .fields ['artist' ].widget ._get_cache_key ()
9695 widget_dict = cache .get (cache_key )
9796 widget_dict ['url' ] = 'yet/another/url'
0 commit comments