1
1
import json
2
2
3
- from django .core import signing
4
3
from django .utils .encoding import smart_str
5
4
6
5
from django_select2 .cache import cache
@@ -21,7 +20,7 @@ def test_get(self, client, artists):
21
20
artist = artists [0 ]
22
21
form = AlbumModelSelect2WidgetForm ()
23
22
assert form .as_p ()
24
- field_id = signing . dumps ( id ( form .fields ['artist' ].widget ))
23
+ field_id = form .fields ['artist' ].widget . widget_id
25
24
url = reverse ('django_select2:auto-json' )
26
25
response = client .get (url , {'field_id' : field_id , 'term' : artist .title })
27
26
assert response .status_code == 200
@@ -43,7 +42,7 @@ def test_wrong_field_id(self, client, artists):
43
42
44
43
def test_field_id_not_found (self , client , artists ):
45
44
artist = artists [0 ]
46
- field_id = signing . dumps ( 123456789 )
45
+ field_id = 'not-exists'
47
46
url = reverse ('django_select2:auto-json' )
48
47
response = client .get (url , {'field_id' : field_id , 'term' : artist .title })
49
48
assert response .status_code == 404
@@ -56,7 +55,7 @@ def test_pagination(self, genres, client):
56
55
search_fields = ['title__icontains' ]
57
56
)
58
57
widget .render ('name' , None )
59
- field_id = signing . dumps ( id ( widget ))
58
+ field_id = widget . widget_id
60
59
61
60
response = client .get (url , {'field_id' : field_id , 'term' : '' })
62
61
assert response .status_code == 200
@@ -77,7 +76,7 @@ def test_label_from_instance(self, artists, client):
77
76
form = AlbumModelSelect2WidgetForm ()
78
77
form .fields ['artist' ].widget = ArtistCustomTitleWidget ()
79
78
assert form .as_p ()
80
- field_id = signing . dumps ( id ( form .fields ['artist' ].widget ))
79
+ field_id = form .fields ['artist' ].widget . widget_id
81
80
82
81
artist = artists [0 ]
83
82
response = client .get (url , {'field_id' : field_id , 'term' : artist .title })
@@ -91,7 +90,7 @@ def test_url_check(self, client, artists):
91
90
artist = artists [0 ]
92
91
form = AlbumModelSelect2WidgetForm ()
93
92
assert form .as_p ()
94
- field_id = signing . dumps ( id ( form .fields ['artist' ].widget ))
93
+ field_id = form .fields ['artist' ].widget . widget_id
95
94
cache_key = form .fields ['artist' ].widget ._get_cache_key ()
96
95
widget_dict = cache .get (cache_key )
97
96
widget_dict ['url' ] = 'yet/another/url'
0 commit comments