Compare commits

...
Author SHA1 Message Date
ivanmkc 0968fb77db Improve download instructions 2022-07-21 19:33:17 -04:00
ivanmkc 471c57132a Fixed issue with numbers in replacement content 2022-07-21 19:29:13 -04:00
ivanmkc 72bad1f6ee Removed replacement of variable comparisons 2022-07-21 15:56:27 -04:00
+15 -1
View File
@@ -36,7 +36,7 @@ Variables in conditionals can also be replaced:
def get_updated_value(content: str, variable_name: str, variable_value: str) -> str:
return re.sub(
rf"({variable_name}.*? = .*?[\",\'])\[.+?\]([\",\'].*?)",
rf"\1{variable_value}\2",
rf"\g<1>{variable_value}\g<2>",
content,
flags=re.M,
)
@@ -80,6 +80,7 @@ def test_region():
)
assert new_content == 'REGION = "us-central1" # @param {type:"string"}'
def test_region_equal_equals_ignore():
# Tests that == is ignored
new_content = get_updated_value(
@@ -88,3 +89,16 @@ def test_region_equal_equals_ignore():
variable_value="us-central1",
)
assert new_content == 'REGION == "[your-region]" # @param {type:"string"}'
def test_service_account():
# Tests that == is ignored
new_content = get_updated_value(
content='SERVICE_ACCOUNT = "[your-service-account]" # @param {type:"string"}',
variable_name="SERVICE_ACCOUNT",
variable_value="12345-compute@developer.gserviceaccount.com",
)
assert (
new_content
== 'SERVICE_ACCOUNT = "12345-compute@developer.gserviceaccount.com" # @param {type:"string"}'
)