File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed
Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 11from rest_framework .test import APITestCase
22from rest_framework .reverse import reverse
3- from rest_framework import status
3+ from rest_framework import status
44from zgw_consumers .constants import APITypes
55from zgw_consumers .test .factories import ServiceFactory
66from vcr .unittest import VCRMixin
@@ -39,4 +39,4 @@ def test_retrieve_choices(self):
3939
4040 self .assertEqual (len (data ), 1 )
4141 self .assertEqual (data [0 ]["label" ], "Test Catalogue (VAVAV)" )
42- self .assertEqual (data [0 ]["value" ], "http://localhost:8003/catalogi/api/v1/catalogussen/ec77ad39-0954-4aeb-bcf2-6f45263cde77" )
42+ self .assertEqual (data [0 ]["value" ], "http://localhost:8003/catalogi/api/v1/catalogussen/ec77ad39-0954-4aeb-bcf2-6f45263cde77" )
Original file line number Diff line number Diff line change 1+ from rest_framework .test import APITestCase
2+ from rest_framework .reverse import reverse
3+ from rest_framework import status
4+ from zgw_consumers .constants import APITypes
5+ from zgw_consumers .test .factories import ServiceFactory
6+
7+ from openbeheer .accounts .tests .factories import UserFactory
8+
9+ class CatalogiChoicesView (APITestCase ):
10+ def test_not_authenticated (self ):
11+
12+ response = self .client .get (reverse ("api:services:choices" ))
13+
14+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
15+
16+ def test_retrieve_choices (self ):
17+ user = UserFactory .create ()
18+ ServiceFactory .create (
19+ api_type = APITypes .ztc ,
20+ api_root = "http://localhost:8003/catalogi/api/v1" ,
21+ client_id = "test-vcr" ,
22+ secret = "test-vcr" ,
23+ slug = "tralala-service" ,
24+ label = "Test Tralala"
25+ )
26+
27+ self .client .force_login (user )
28+ response = self .client .get (reverse ("api:services:choices" ))
29+
30+ self .assertEqual (response .status_code , status .HTTP_200_OK )
31+
32+ data = response .json ()
33+
34+ self .assertEqual (len (data ), 1 )
35+ self .assertEqual (data [0 ]["label" ], "Test Tralala" )
36+ self .assertEqual (data [0 ]["value" ], "tralala-service" )
You can’t perform that action at this time.
0 commit comments