@@ -28,6 +28,7 @@ def test_happy_path(
2828
2929 body ["member" ] = [organisation .identifier ]
3030 body ["contact_details" ] = contact .identifier
31+ body ["contact" ] = [contact .identifier ]
3132
3233 response = client .post ("/organisations" , json = body , headers = {"Authorization" : "Fake token" })
3334 assert response .status_code == 200 , response .json ()
@@ -47,6 +48,15 @@ def test_happy_path(
4748 assert response_json ["type" ] == "research institute"
4849 assert response_json ["member" ] == body ["member" ]
4950 assert response_json ["contact_details" ] == body ["contact_details" ]
51+ assert response_json ["contacts" ][0 ]["name" ] == "Aaron Bar"
52+ assert response_json ["contacts" ][0 ]["telephone" ] == ["0032 xxxx xxxx" ]
53+ assert response_json ["contacts" ][0 ]["email" ] == ["a@b.com" ]
54+ assert response_json ["contacts" ][0 ]["location" ] == [
55+ {
56+ "address" : {"country" : "NED" , "street" : "Street Name 10" , "postal_code" : "1234AB" },
57+ "geo" : {"latitude" : 37.42242 , "longitude" : - 122.08585 , "elevation_millimeters" : 2000 },
58+ }
59+ ]
5060
5161 # response = client.delete("/organisations/1", headers={"Authorization": "Fake token"})
5262 # assert response.status_code == 200
@@ -63,3 +73,27 @@ def test_happy_path(
6373
6474 response = client .delete (f"/organisations/{ identifier } " , headers = {"Authorization" : "Fake token" })
6575 assert response .status_code == 200 , response .json ()
76+
77+
78+ def test_ai_resource_contacts_field_is_ignored (
79+ client : TestClient ,
80+ mocked_privileged_token : Mock ,
81+ organisation : Organisation ,
82+ contact : Contact ,
83+ body_agent : dict ,
84+ auto_publish : None ,
85+ ):
86+ with DbSession () as session :
87+ session .add (contact )
88+ session .commit ()
89+ session .refresh (contact )
90+
91+ body = copy .copy (body_agent )
92+ body ["contacts" ] = [contact .json ()]
93+ response = client .post ("/organisations" , json = body , headers = {"Authorization" : "Fake token" })
94+ assert response .status_code == 200 , response .json ()
95+ identifier = response .json ()['identifier' ]
96+
97+ response = client .get (f"/organisations/{ identifier } " )
98+ assert response .status_code == 200 , response .json ()
99+ assert response .json ()["contacts" ] == []
0 commit comments