9
9
def test_create_organization_success (auth_client , session , test_user ):
10
10
"""Test successful organization creation"""
11
11
response = auth_client .post (
12
- "/organizations/create" ,
12
+ app . url_path_for ( "create_organization" ) ,
13
13
data = {"name" : "New Test Organization" },
14
14
follow_redirects = False
15
15
)
@@ -66,7 +66,7 @@ def test_create_organization_success(auth_client, session, test_user):
66
66
def test_create_organization_empty_name (auth_client ):
67
67
"""Test organization creation with empty name"""
68
68
response = auth_client .post (
69
- "/organizations/create" ,
69
+ app . url_path_for ( "create_organization" ) ,
70
70
data = {"name" : " " },
71
71
follow_redirects = True
72
72
)
@@ -82,7 +82,7 @@ def test_create_organization_duplicate_name(auth_client, session, test_organizat
82
82
org_count_before = len (session .exec (select (Organization )).all ())
83
83
84
84
response = auth_client .post (
85
- "/organizations/create" ,
85
+ app . url_path_for ( "create_organization" ) ,
86
86
data = {"name" : test_organization .name },
87
87
follow_redirects = False
88
88
)
@@ -105,7 +105,7 @@ def test_create_organization_duplicate_name(auth_client, session, test_organizat
105
105
def test_create_organization_unauthenticated (unauth_client ):
106
106
"""Test organization creation without authentication"""
107
107
response = unauth_client .post (
108
- "/organizations/create" ,
108
+ app . url_path_for ( "create_organization" ) ,
109
109
data = {"name" : "Unauthorized Org" },
110
110
follow_redirects = False
111
111
)
@@ -130,7 +130,7 @@ def test_update_organization_success(
130
130
131
131
new_name = "Updated Organization Name"
132
132
response = auth_client .post (
133
- f"/organizations/update/ { test_organization .id } " ,
133
+ app . url_path_for ( "update_organization" , org_id = test_organization .id ) ,
134
134
data = {"id" : str (test_organization .id ), "name" : new_name },
135
135
follow_redirects = False
136
136
)
@@ -156,7 +156,7 @@ def test_update_organization_unauthorized(auth_client, session, test_organizatio
156
156
session .commit ()
157
157
158
158
response = auth_client .post (
159
- f"/organizations/update/ { test_organization .id } " ,
159
+ app . url_path_for ( "update_organization" , org_id = test_organization .id ) ,
160
160
data = {
161
161
"id" : test_organization .id ,
162
162
"name" : "Unauthorized Update"
@@ -183,7 +183,7 @@ def test_update_organization_duplicate_name(auth_client, session, test_organizat
183
183
session .commit ()
184
184
185
185
response = auth_client .post (
186
- f"/organizations/update/ { test_organization .id } " ,
186
+ app . url_path_for ( "update_organization" , org_id = test_organization .id ) ,
187
187
data = {
188
188
"id" : test_organization .id ,
189
189
"name" : "Existing Org"
@@ -206,7 +206,7 @@ def test_update_organization_empty_name(auth_client, session, test_organization,
206
206
session .commit ()
207
207
208
208
response = auth_client .post (
209
- f"/organizations/update/ { test_organization .id } " ,
209
+ app . url_path_for ( "update_organization" , org_id = test_organization .id ) ,
210
210
data = {
211
211
"id" : test_organization .id ,
212
212
"name" : " "
@@ -221,7 +221,7 @@ def test_update_organization_empty_name(auth_client, session, test_organization,
221
221
def test_update_organization_unauthenticated (unauth_client , test_organization ):
222
222
"""Test organization update without authentication"""
223
223
response = unauth_client .post (
224
- f"/organizations/update/ { test_organization .id } " ,
224
+ app . url_path_for ( "update_organization" , org_id = test_organization .id ) ,
225
225
data = {
226
226
"id" : test_organization .id ,
227
227
"name" : "Unauthorized Update"
@@ -246,12 +246,12 @@ def test_delete_organization_success(auth_client, session, test_organization, te
246
246
session .commit ()
247
247
248
248
response = auth_client .post (
249
- f"/organizations/delete/ { org_id } " ,
249
+ app . url_path_for ( "delete_organization" , org_id = org_id ) ,
250
250
follow_redirects = False
251
251
)
252
252
253
253
assert response .status_code == 303 # Redirect status code
254
- assert "/profile" in response .headers ["location" ]
254
+ assert app . url_path_for ( "read_profile" ) in response .headers ["location" ]
255
255
256
256
# Expire all objects in the session to force a refresh from the database
257
257
session .expire_all ()
@@ -266,7 +266,7 @@ def test_delete_organization_unauthorized(auth_client_member, session, test_orga
266
266
"""Test organization deletion without proper permissions"""
267
267
# Use auth_client_member, who belongs to the org but has no delete permission
268
268
response = auth_client_member .post (
269
- f"/organizations/delete/ { test_organization .id } " ,
269
+ app . url_path_for ( "delete_organization" , org_id = test_organization .id ) ,
270
270
follow_redirects = False
271
271
)
272
272
@@ -280,7 +280,7 @@ def test_delete_organization_unauthorized(auth_client_member, session, test_orga
280
280
def test_delete_organization_not_member (auth_client_non_member , session , test_organization ):
281
281
"""Test organization deletion by non-member"""
282
282
response = auth_client_non_member .post (
283
- f"/organizations/delete/ { test_organization .id } " ,
283
+ app . url_path_for ( "delete_organization" , org_id = test_organization .id ) ,
284
284
follow_redirects = False
285
285
)
286
286
@@ -294,7 +294,7 @@ def test_delete_organization_not_member(auth_client_non_member, session, test_or
294
294
def test_delete_organization_unauthenticated (unauth_client , test_organization ):
295
295
"""Test organization deletion without authentication"""
296
296
response = unauth_client .post (
297
- f"/organizations/delete/ { test_organization .id } " ,
297
+ app . url_path_for ( "delete_organization" , org_id = test_organization .id ) ,
298
298
follow_redirects = False
299
299
)
300
300
@@ -320,7 +320,7 @@ def test_delete_organization_cascade(auth_client, session, test_organization, te
320
320
session .commit ()
321
321
322
322
response = auth_client .post (
323
- f"/organizations/delete/ { org_id } " ,
323
+ app . url_path_for ( "delete_organization" , org_id = org_id ) ,
324
324
follow_redirects = False
325
325
)
326
326
@@ -341,7 +341,7 @@ def test_delete_organization_cascade(auth_client, session, test_organization, te
341
341
def test_read_organization_as_owner (auth_client_owner , test_organization ):
342
342
"""Test accessing organization page as an owner"""
343
343
response = auth_client_owner .get (
344
- f"/organizations/ { test_organization .id } " ,
344
+ app . url_path_for ( "read_organization" , org_id = test_organization .id ) ,
345
345
follow_redirects = False
346
346
)
347
347
@@ -360,7 +360,7 @@ def test_read_organization_as_owner(auth_client_owner, test_organization):
360
360
def test_read_organization_as_admin (auth_client_admin , test_organization ):
361
361
"""Test accessing organization page as an admin"""
362
362
response = auth_client_admin .get (
363
- f"/organizations/ { test_organization .id } " ,
363
+ app . url_path_for ( "read_organization" , org_id = test_organization .id ) ,
364
364
follow_redirects = False
365
365
)
366
366
@@ -379,7 +379,7 @@ def test_read_organization_as_admin(auth_client_admin, test_organization):
379
379
def test_read_organization_as_member (auth_client_member , test_organization ):
380
380
"""Test accessing organization page as a regular member"""
381
381
response = auth_client_member .get (
382
- f"/organizations/ { test_organization .id } " ,
382
+ app . url_path_for ( "read_organization" , org_id = test_organization .id ) ,
383
383
follow_redirects = False
384
384
)
385
385
@@ -398,7 +398,7 @@ def test_read_organization_as_member(auth_client_member, test_organization):
398
398
def test_read_organization_as_non_member (auth_client_non_member , test_organization ):
399
399
"""Test accessing organization page as a non-member"""
400
400
response = auth_client_non_member .get (
401
- f"/organizations/ { test_organization .id } " ,
401
+ app . url_path_for ( "read_organization" , org_id = test_organization .id ) ,
402
402
follow_redirects = False
403
403
)
404
404
@@ -410,7 +410,7 @@ def test_read_organization_as_non_member(auth_client_non_member, test_organizati
410
410
def test_organization_page_displays_members_correctly (auth_client_owner , org_admin_user , org_member_user , test_organization ):
411
411
"""Test that members and their roles are displayed correctly"""
412
412
response = auth_client_owner .get (
413
- f"/organizations/ { test_organization .id } " ,
413
+ app . url_path_for ( "read_organization" , org_id = test_organization .id ) ,
414
414
follow_redirects = False
415
415
)
416
416
@@ -463,7 +463,7 @@ def test_empty_organization_displays_no_members_message(auth_client_owner, sessi
463
463
session .commit ()
464
464
465
465
response = auth_client_owner .get (
466
- f"/organizations/ { empty_org .id } " ,
466
+ app . url_path_for ( "read_organization" , org_id = empty_org .id ) ,
467
467
follow_redirects = False
468
468
)
469
469
@@ -481,14 +481,14 @@ def test_invite_user_success(auth_client_owner, session, test_organization, non_
481
481
482
482
# Send invite
483
483
response = auth_client_owner .post (
484
- f"/organizations/invite/ { test_organization .id } " ,
484
+ app . url_path_for ( "invite_member" , org_id = test_organization .id ) ,
485
485
data = {"email" : non_member_user .account .email },
486
486
follow_redirects = False
487
487
)
488
488
489
489
# Should redirect back to organization page
490
490
assert response .status_code == 303
491
- assert f"/organizations/ { test_organization .id } " in response .headers ["location" ]
491
+ assert app . url_path_for ( "read_organization" , org_id = test_organization .id ) in response .headers ["location" ]
492
492
493
493
# Verify database state - user should now have the Member role
494
494
session .refresh (non_member_user )
@@ -508,7 +508,7 @@ def test_invite_user_success(auth_client_owner, session, test_organization, non_
508
508
def test_invite_nonexistent_user (auth_client_owner , test_organization ):
509
509
"""Test inviting a user that doesn't exist in the system"""
510
510
response = auth_client_owner .post (
511
- f"/organizations/invite/ { test_organization .id } " ,
511
+ app . url_path_for ( "invite_member" , org_id = test_organization .id ) ,
512
512
data = {
"email" :
"[email protected] " },
513
513
follow_redirects = True
514
514
)
@@ -521,7 +521,7 @@ def test_invite_nonexistent_user(auth_client_owner, test_organization):
521
521
def test_invite_existing_member (auth_client_owner , test_organization , org_member_user ):
522
522
"""Test inviting a user who is already a member"""
523
523
response = auth_client_owner .post (
524
- f"/organizations/invite/ { test_organization .id } " ,
524
+ app . url_path_for ( "invite_member" , org_id = test_organization .id ) ,
525
525
data = {"email" : org_member_user .account .email },
526
526
follow_redirects = True
527
527
)
@@ -534,7 +534,7 @@ def test_invite_existing_member(auth_client_owner, test_organization, org_member
534
534
def test_invite_without_permission (auth_client_member , test_organization , non_member_user ):
535
535
"""Test inviting a user without having the INVITE_USER permission"""
536
536
response = auth_client_member .post (
537
- f"/organizations/invite/ { test_organization .id } " ,
537
+ app . url_path_for ( "invite_member" , org_id = test_organization .id ) ,
538
538
data = {"email" : non_member_user .account .email },
539
539
follow_redirects = True
540
540
)
0 commit comments