File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,19 @@ def test_simplest_endpoint(self):
28
28
"/simple" , consumer = self .consumer , expected_status_code = HTTPStatus .OK
29
29
)
30
30
31
+ def test_dict_endpoint (self ):
32
+ resp = self .client .get (
33
+ "/dict" , consumer = self .consumer , expected_status_code = HTTPStatus .OK
34
+ )
35
+ data = resp .json ()
36
+ self .assertEqual (data ,
37
+ {'test' : {
38
+ 'pk' : 1 ,
39
+ 'int_field' : 1 ,
40
+ '__expandable__' : ['expandable_dict' , 'expandable_string' ]
41
+ }
42
+ })
43
+
31
44
def test_typed_parameter (self ):
32
45
response = self .client .get (
33
46
"/simple?int_type_field=not_an_int" ,
Original file line number Diff line number Diff line change 13
13
14
14
UUID4_REGEX = r"[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}"
15
15
16
- urlpatterns = [url (r"^simple" , resource_adapter (get = views .SimpleEndpointDefinition ))]
16
+ urlpatterns = [
17
+ url (r"^simple" , resource_adapter (get = views .SimpleEndpointDefinition )),
18
+ url (r"^dict" , resource_adapter (get = views .DictEndpointDefinition )),
19
+ ]
Original file line number Diff line number Diff line change @@ -34,3 +34,14 @@ def execution_decider(self):
34
34
@staticmethod
35
35
def deferred_task (inst ):
36
36
cache .set ("deferred_task_called" , True )
37
+
38
+
39
+ class DictEndpointDefinition (EndpointDefinition ):
40
+ def is_authorized (self ):
41
+ return True
42
+
43
+ @endpoint_resource (type = TestModel )
44
+ def resource (self ):
45
+ return {
46
+ 'test' : TestModel .objects .create (int_field = 1 )
47
+ }
You can’t perform that action at this time.
0 commit comments