Skip to content

Commit a061172

Browse files
Bugfix - fix condition for apply_configlet() in blueprint.py (#43)
* replace single quote with double quote * fix location where replace is located * add same fix to id_in as well * fix linting * fix tests * Bump version number according to semvar - minor bump due to new feature
1 parent ea5b1f8 commit a061172

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

aos/blueprint.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,8 @@ def apply_configlet(
748748
c_path = f"/api/blueprints/{bp_id}/configlets"
749749
aos_configlets = AosConfiglets(self.rest)
750750
configlet = aos_configlets.get_configlet(conf_id=configlet_id)
751-
role_in = f"role in {role}"
752-
id_in = f"id in {system_id}"
751+
role_in = f"role in {role}".replace("'", '"')
752+
id_in = f"id in {system_id}".replace("'", '"')
753753

754754
if role and system_id:
755755
condition = f"{role_in} and {id_in}"

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
NAME = "apstra-api-python"
1111

12-
VERSION = '0.1.21'
12+
VERSION = '0.2.0'
1313

1414

1515
REQUIRES = (["requests==2.24.0"],)

tests/test_blueprint.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,8 @@ def test_apply_configlet(
883883
json_body = {
884884
"configlet": conf_dict,
885885
"label": conf_dict["display_name"],
886-
"condition": f"role in {conf_role}",
886+
# apstra expects json with double quotes instead of single
887+
"condition": f"role in {conf_role}".replace("'", '"'),
887888
}
888889

889890
aos_session.request.assert_called_with(
@@ -960,7 +961,8 @@ def test_apply_configlet_combined_conditions(
960961
json_body = {
961962
"configlet": conf_dict,
962963
"label": conf_dict["display_name"],
963-
"condition": f"role in {conf_role} and id in {conf_ids}",
964+
# apstra expects json with double quote instead of single
965+
"condition": f"role in {conf_role} and id in {conf_ids}".replace("'", '"'),
964966
}
965967

966968
aos_session.request.assert_called_with(

0 commit comments

Comments
 (0)