@@ -136,18 +136,35 @@ def test_retrieve_organization_not_exist(admin_client: APIClient):
136
136
137
137
138
138
@pytest .mark .django_db
139
- def test_partial_update_organization (
140
- default_organization : models .Organization ,
141
- admin_client : APIClient ,
139
+ def test_partial_update_organization_success (
140
+ new_organization : models .Organization ,
141
+ superuser_client : APIClient ,
142
142
):
143
143
new_data = {"name" : "new-name" , "description" : "New Description" }
144
- response = admin_client .patch (
145
- f"{ api_url_v1 } /organizations/{ default_organization .id } /" , data = new_data
144
+ response = superuser_client .patch (
145
+ f"{ api_url_v1 } /organizations/{ new_organization .id } /" , data = new_data
146
146
)
147
147
assert response .status_code == status .HTTP_200_OK
148
148
149
- default_organization .refresh_from_db ()
150
- assert_organization_data (response .data , default_organization )
149
+ new_organization .refresh_from_db ()
150
+ assert_organization_data (response .data , new_organization )
151
+
152
+
153
+ @pytest .mark .django_db
154
+ def test_partial_update_default_organization_exception (
155
+ default_organization : models .Organization ,
156
+ superuser_client : APIClient ,
157
+ ):
158
+ new_data = {"name" : "new-name" , "description" : "New Description" }
159
+ response = superuser_client .patch (
160
+ f"{ api_url_v1 } /organizations/{ default_organization .id } /" , data = new_data
161
+ )
162
+ assert response .status_code == status .HTTP_409_CONFLICT
163
+ assert (
164
+ response .data ["detail" ]
165
+ == "The default organization cannot be modified."
166
+ )
167
+ assert models .Organization .objects .get (id = default_organization .id )
151
168
152
169
153
170
@pytest .mark .django_db
0 commit comments