@@ -114,7 +114,7 @@ def test_retrieve_zaaktypen_choices(self):
114
114
115
115
self .assertEqual (response .status_code , status .HTTP_200_OK )
116
116
self .assertEqual (
117
- response .json (),
117
+ sorted ( response .json (), key = lambda choice : choice [ "label" ] ),
118
118
[
119
119
{
120
120
"value" : "http://catalogi-api.nl/catalogi/api/v1/zaakypen/111-111-111,http://catalogi-api.nl/catalogi/api/v1/zaakypen/222-222-222" ,
@@ -685,7 +685,7 @@ def setUp(self):
685
685
self .addCleanup (retrieve_paginated_type .cache_clear )
686
686
687
687
def test_not_authenticated (self ):
688
- endpoint = reverse ("api:retrieve-resultaattype-choices" )
688
+ endpoint = reverse ("api:retrieve-external- resultaattype-choices" )
689
689
690
690
response = self .client .get (endpoint )
691
691
@@ -717,7 +717,9 @@ def test_retrieve_choices(self, m):
717
717
)
718
718
719
719
self .client .force_authenticate (user = user )
720
- response = self .client .get (reverse ("api:retrieve-resultaattype-choices" ))
720
+ response = self .client .get (
721
+ reverse ("api:retrieve-external-resultaattype-choices" )
722
+ )
721
723
722
724
self .assertEqual (response .status_code , status .HTTP_200_OK )
723
725
self .assertEqual (
@@ -760,12 +762,16 @@ def test_retrieve_choices_caches_request(self, m):
760
762
)
761
763
762
764
self .client .force_authenticate (user = user )
763
- response = self .client .get (reverse ("api:retrieve-resultaattype-choices" ))
765
+ response = self .client .get (
766
+ reverse ("api:retrieve-external-resultaattype-choices" )
767
+ )
764
768
765
769
self .assertEqual (response .status_code , status .HTTP_200_OK )
766
770
767
771
# Repeat request
768
- response = self .client .get (reverse ("api:retrieve-resultaattype-choices" ))
772
+ response = self .client .get (
773
+ reverse ("api:retrieve-external-resultaattype-choices" )
774
+ )
769
775
770
776
self .assertEqual (response .status_code , status .HTTP_200_OK )
771
777
@@ -963,3 +969,136 @@ def test_retrieve_choices_caches_request(self, m):
963
969
964
970
# Only one call to openzaak
965
971
self .assertEqual (len (m .request_history ), 1 )
972
+
973
+
974
+ class InternalResultaattypeChoicesViewTest (APITestCase ):
975
+ def setUp (self ):
976
+ super ().setUp ()
977
+
978
+ self .addCleanup (cache .clear )
979
+
980
+ def test_not_authenticated (self ):
981
+ endpoint = reverse ("api:retrieve-internal-resultaattype-choices" )
982
+
983
+ response = self .client .get (endpoint )
984
+
985
+ self .assertEqual (response .status_code , status .HTTP_403_FORBIDDEN )
986
+
987
+ def test_get_all_choices (self ):
988
+ user = UserFactory .create ()
989
+
990
+ ZaakFactory .create (
991
+ post___expand = {
992
+ "resultaat" : {
993
+ "url" : "http://localhost:8003/zaken/api/v1/resultaten/821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
994
+ "uuid" : "821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
995
+ "_expand" : {
996
+ "resultaattype" : {
997
+ "url" : "http://localhost:8003/catalogi/api/v1/resultaattypen/111-111-111" ,
998
+ "omschrijving" : "Afgehandeld" ,
999
+ }
1000
+ },
1001
+ "toelichting" : "Testing resultaten" ,
1002
+ "resultaattype" : "http://localhost:8003/catalogi/api/v1/resultaattypen/111-111-111" ,
1003
+ }
1004
+ },
1005
+ )
1006
+ ZaakFactory .create (
1007
+ post___expand = {
1008
+ "resultaat" : {
1009
+ "url" : "http://localhost:8003/zaken/api/v1/resultaten/821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
1010
+ "uuid" : "821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
1011
+ "_expand" : {
1012
+ "resultaattype" : {
1013
+ "url" : "http://localhost:8003/catalogi/api/v1/resultaattypen/222-222-222" ,
1014
+ "omschrijving" : "Lopend" ,
1015
+ }
1016
+ },
1017
+ "toelichting" : "Testing resultaten" ,
1018
+ "resultaattype" : "http://localhost:8003/catalogi/api/v1/resultaattypen/222-222-222" ,
1019
+ }
1020
+ },
1021
+ )
1022
+
1023
+ self .client .force_authenticate (user = user )
1024
+ response = self .client .get (
1025
+ reverse ("api:retrieve-internal-resultaattype-choices" )
1026
+ )
1027
+
1028
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
1029
+
1030
+ data = response .json ()
1031
+
1032
+ self .assertEqual (len (data ), 2 )
1033
+ self .assertEqual (
1034
+ [
1035
+ {
1036
+ "value" : "http://localhost:8003/catalogi/api/v1/resultaattypen/111-111-111" ,
1037
+ "label" : "Afgehandeld" ,
1038
+ },
1039
+ {
1040
+ "value" : "http://localhost:8003/catalogi/api/v1/resultaattypen/222-222-222" ,
1041
+ "label" : "Lopend" ,
1042
+ },
1043
+ ],
1044
+ sorted (data , key = lambda choice : choice ["value" ]),
1045
+ )
1046
+
1047
+ def test_get_choices_with_filters (self ):
1048
+ user = UserFactory .create ()
1049
+
1050
+ ZaakFactory .create (
1051
+ identificatie = "ZAAK-01" ,
1052
+ post___expand = {
1053
+ "resultaat" : {
1054
+ "url" : "http://localhost:8003/zaken/api/v1/resultaten/821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
1055
+ "uuid" : "821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
1056
+ "_expand" : {
1057
+ "resultaattype" : {
1058
+ "url" : "http://localhost:8003/catalogi/api/v1/resultaattypen/111-111-111" ,
1059
+ "omschrijving" : "Afgehandeld" ,
1060
+ }
1061
+ },
1062
+ "toelichting" : "Testing resultaten" ,
1063
+ "resultaattype" : "http://localhost:8003/catalogi/api/v1/resultaattypen/111-111-111" ,
1064
+ }
1065
+ },
1066
+ )
1067
+ ZaakFactory .create (
1068
+ identificatie = "ZAAK-02" ,
1069
+ post___expand = {
1070
+ "resultaat" : {
1071
+ "url" : "http://localhost:8003/zaken/api/v1/resultaten/821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
1072
+ "uuid" : "821b4d8f-3244-4ece-8d33-791fa6d2a2f3" ,
1073
+ "_expand" : {
1074
+ "resultaattype" : {
1075
+ "url" : "http://localhost:8003/catalogi/api/v1/resultaattypen/222-222-222" ,
1076
+ "omschrijving" : "Lopend" ,
1077
+ }
1078
+ },
1079
+ "toelichting" : "Testing resultaten" ,
1080
+ "resultaattype" : "http://localhost:8003/catalogi/api/v1/resultaattypen/222-222-222" ,
1081
+ }
1082
+ },
1083
+ )
1084
+
1085
+ self .client .force_authenticate (user = user )
1086
+ endpoint = furl (reverse ("api:retrieve-internal-resultaattype-choices" ))
1087
+ endpoint .args ["identificatie" ] = "ZAAK-01"
1088
+
1089
+ response = self .client .get (endpoint .url )
1090
+
1091
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
1092
+
1093
+ data = response .json ()
1094
+
1095
+ self .assertEqual (len (data ), 1 )
1096
+ self .assertEqual (
1097
+ [
1098
+ {
1099
+ "value" : "http://localhost:8003/catalogi/api/v1/resultaattypen/111-111-111" ,
1100
+ "label" : "Afgehandeld" ,
1101
+ },
1102
+ ],
1103
+ data ,
1104
+ )
0 commit comments