You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "gokulakrishnansvm (via GitHub)" <gi...@apache.org> on 2023/07/25 05:25:14 UTC

[GitHub] [trafficcontrol] gokulakrishnansvm commented on a diff in pull request #7604: Added api contract profile parameters test case

gokulakrishnansvm commented on code in PR #7604:
URL: https://github.com/apache/trafficcontrol/pull/7604#discussion_r1273012765


##########
traffic_ops/testing/api_contract/v4/conftest.py:
##########
@@ -1643,3 +1643,43 @@ def delivery_services_regex_data_post(to_session: TOSession, request_template_da
 	if msg is None:
 		logger.error("delivery_services_regex returned by Traffic Ops is missing an 'id' property")
 		pytest.fail("Response from delete request is empty, Failing test_case")
+
+  
+@pytest.fixture(name="profile_parameters_post_data")
+def profile_parameters_post_data(to_session: TOSession, request_template_data: list[JSONData],
+		profile_post_data:dict[str, object], parameter_post_data:dict[str, object]
+		) -> dict[str, object]:
+	"""
+	PyTest Fixture to create POST data for profile parameters endpoint.
+	:param to_session: Fixture to get Traffic Ops session.
+	:param request_template_data: Fixture to get profile parameters request template from a prerequisites file.
+	:returns: Sample POST data and the actual API response.
+	"""
+
+	profile_parameters = check_template_data(request_template_data["profile_parameters"], "profile_parameters")
+
+	# Return new post data and post response from profile parameters POST request
+	profile_get_response = to_session.get_profiles()
+	profile_data = profile_get_response [0][0]
+	profile_id = profile_data.get("id")
+
+	parameter_get_response = to_session.get_parameters()
+	parameter_data = parameter_get_response [0][0]
+	parameter_id = parameter_data.get("id")
+
+	profile_parameters["profileId"] = profile_post_data["id"]
+	profile_parameters["parameterId"] = parameter_post_data["id"]
+
+	logger.info("New profile_parameter data to hit POST method %s", profile_parameters)
+
+	# Hitting profile parameters POST method
+	response: tuple[JSONData, requests.Response] = to_session.associate_paramater_to_profile(profile_id=profile_id, data=profile_parameters)
+	resp_obj = check_template_data(response, "profile_parameters")
+	yield resp_obj
+	profile_id = resp_obj.get("profileId")
+	parameter_id = resp_obj.get("parameterId")
+	msg = to_session.delete_profile_parameter_association_by_id(profile_id=profile_id, parameter_id=parameter_id)
+	logger.info("Deleting Profile Parameters data... %s", msg)
+	if msg is None:
+		logger.error("Profile Parameter returned by Traffic Ops is missing a 'profile_id' property")
+    pytest.fail("Response from delete request is empty, Failing test_case")

Review Comment:
   Check this indendation at line 1685, That's why test case is failing..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org