@@ -571,31 +571,40 @@ def test_assign_referrer_to_user(auth_client, user, referrer):
571571
572572def test_create_project_url (auth_client , project , url_type ):
573573 payload = {
574- # "project": project.pk,
575- # "url_type": url_type.pk,
574+ "project" : project .pk ,
575+ "url_type" : url_type .pk ,
576576 "name" : "This is a test project url" ,
577577 "external_id" : "This is a test external id" ,
578578 "url" : "https://test.com" ,
579579 }
580580 res = auth_client .post (PROJECT_URLS_URL , payload )
581581 assert res .status_code == status .HTTP_201_CREATED
582- # assert res.data["project"] == payload["project"]
583- # assert res.data["url_type"] == payload["url_type"]
582+ assert res .data ["project" ] == payload ["project" ]
583+ assert res .data ["url_type" ] == payload ["url_type" ]
584584 assert res .data ["name" ] == payload ["name" ]
585585 assert res .data ["external_id" ] == payload ["external_id" ]
586586 assert res .data ["url" ] == payload ["url" ]
587587
588588
589589def test_project_url_project_relationship (auth_client , project_url , project ):
590+ # Update project_url to link it to a specific project
590591 res = auth_client .patch (
591592 reverse ("project-url-detail" , kwargs = {"pk" : project_url .pk }),
592593 {"project" : project .pk },
593594 )
594595 assert res .status_code == status .HTTP_200_OK
595- res = auth_client .get (PROJECT_URLS_URL )
596- project .exists = False
597- for item in res .data :
598- if item ["project" ] == project .pk :
599- project_exists = True
600- break
601- assert project_exists is True
596+
597+ # Verify the relationship was set by checking the response directly
598+ assert res .data ["project" ] == project .pk
599+
600+
601+ def test_project_url_url_type_relationship (auth_client , url_type , project_url ):
602+ # Update project_url to link it to a specific url_type
603+ res = auth_client .patch (
604+ reverse ("project-url-detail" , kwargs = {"pk" : project_url .pk }),
605+ {"url_type" : url_type .pk },
606+ )
607+ assert res .status_code == status .HTTP_200_OK
608+
609+ # Verify the url_type relationship was set correctly
610+ assert res .data ["url_type" ] == url_type .pk
0 commit comments