Skip to content

Commit 54b4a47

Browse files
authored
Rename MONITORED_CONTENT_GUID to a more generic MONITORED_CONTENT (#269)
1 parent c57aaac commit 54b4a47

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

extensions/content-health-monitor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following environment variables are required when previewing the report loca
1212
# Required variables
1313
CONNECT_SERVER # Set automatically when deployed to Connect
1414
CONNECT_API_KEY # Set automatically when deployed to Connect
15-
MONITORED_CONTENT_GUID # GUID for the content to monitor
15+
MONITORED_CONTENT # GUID for the content to monitor
1616
```
1717

1818
# Usage

extensions/content-health-monitor/content-health-monitor.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ current_user_name = utils.DEFAULT_USER_NAME # Will be updated if user info can
3232
# Read environment variables
3333
connect_server = utils.get_env_var("CONNECT_SERVER", state) # Automatically provided by Connect, must be set when previewing locally
3434
api_key = utils.get_env_var("CONNECT_API_KEY", state) # Automatically provided by Connect, must be set when previewing locally
35-
monitored_content_guid = utils.get_env_var("MONITORED_CONTENT_GUID", state)
35+
monitored_content_guid = utils.get_env_var("MONITORED_CONTENT", state)
3636
3737
# Extract GUID if it's a string or URL containing a GUID
3838
if monitored_content_guid:

extensions/content-health-monitor/content_health_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def get_env_var(var_name, state, description=""):
6363
state.show_instructions = True
6464

6565
# Generic instruction for most variables
66-
if var_name != "MONITORED_CONTENT_GUID":
66+
if var_name != "MONITORED_CONTENT":
6767
instruction = f"Please set the <code>{var_name}</code> environment variable."
68-
# Detailed instructions for MONITORED_CONTENT_GUID
68+
# Detailed instructions for MONITORED_CONTENT
6969
else:
7070
one_tab = "&nbsp;&nbsp;&nbsp;&nbsp;" # For indentation in HTML
7171
two_tabs = f"{one_tab}{one_tab}" # For deeper indentation
@@ -147,7 +147,7 @@ def extract_guid(input_string):
147147
url_pattern = re.compile(r'^https?://', re.IGNORECASE)
148148
if url_pattern.match(input_string):
149149
error_message = (
150-
f"The URL provided in <code>MONITORED_CONTENT_GUID</code> does not contain a valid GUID. "
150+
f"The URL provided in <code>MONITORED_CONTENT</code> does not contain a valid GUID. "
151151
f"The URL should contain a GUID like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code><br><br>"
152152
f"The URL provided is: <a href=\"{input_string}\" target=\"_blank\" rel=\"noopener noreferrer\">{input_string}</a><br><br>"
153153
f"Please update your environment variable with a valid GUID or a URL containing a GUID."
@@ -156,7 +156,7 @@ def extract_guid(input_string):
156156

157157
# Handle non-URL strings that don't match GUID format
158158
error_message = (
159-
f"The value provided in <code>MONITORED_CONTENT_GUID</code> is not a valid GUID. "
159+
f"The value provided in <code>MONITORED_CONTENT</code> is not a valid GUID. "
160160
f"A valid GUID looks like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code><br><br>"
161161
f"The provided value was: <code>{input_string}</code><br><br>"
162162
f"Please update your environment variable with a valid GUID or a URL containing a GUID."
@@ -376,7 +376,7 @@ def create_error_box(guid, error_msg):
376376
</div>
377377
378378
<div style="{CSS_FOOTER_STYLE}">
379-
Please check that your <code>MONITORED_CONTENT_GUID</code> environment variable contains a valid content identifier.
379+
Please check that your <code>MONITORED_CONTENT</code> environment variable contains a valid content identifier.
380380
</div>
381381
</div>
382382
"""
@@ -395,7 +395,7 @@ def create_no_results_box():
395395
<li>There was an issue connecting to the specified content</li>
396396
<li>The environment is properly configured but there was an error that caused no data to be returned</li>
397397
</ul>
398-
<p>Please check your MONITORED_CONTENT_GUID environment variable and ensure it contains a valid content identifier.</p>
398+
<p>Please check your MONITORED_CONTENT environment variable and ensure it contains a valid content identifier.</p>
399399
</div>
400400
</div>
401401
"""

extensions/content-health-monitor/test_content_health_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def test_get_env_var_missing_standard(self, state):
152152
assert f"Please set the <code>{var_name}</code> environment variable." in state.instructions[0]
153153

154154
def test_get_env_var_missing_canary_guid(self, state):
155-
"""Test get_env_var when MONITORED_CONTENT_GUID is missing"""
155+
"""Test get_env_var when MONITORED_CONTENT is missing"""
156156
# Setup
157-
var_name = "MONITORED_CONTENT_GUID"
157+
var_name = "MONITORED_CONTENT"
158158
clear_env_var(var_name) # Ensure it doesn't exist
159159

160160
# Execute
@@ -164,7 +164,7 @@ def test_get_env_var_missing_canary_guid(self, state):
164164
assert result == ""
165165
assert state.show_instructions
166166
assert len(state.instructions) == 1
167-
assert "you must configure the <code>MONITORED_CONTENT_GUID</code> environment variable" in state.instructions[0]
167+
assert "you must configure the <code>MONITORED_CONTENT</code> environment variable" in state.instructions[0]
168168
assert f"<code>{var_name}</code>" in state.instructions[0]
169169

170170
def test_get_env_var_with_description(self, state):
@@ -290,7 +290,7 @@ def test_extract_guid_with_url_no_guid(self):
290290
# Assert
291291
assert result == input_string
292292
assert error_message is not None
293-
assert "The URL provided in <code>MONITORED_CONTENT_GUID</code> does not contain a valid GUID" in error_message
293+
assert "The URL provided in <code>MONITORED_CONTENT</code> does not contain a valid GUID" in error_message
294294
assert "The URL should contain a GUID like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code>" in error_message
295295
assert f"<a href=\"{input_string}\" target=\"_blank\" rel=\"noopener noreferrer\">" in error_message
296296
assert "Please update your environment variable with a valid GUID or a URL containing a GUID" in error_message
@@ -306,7 +306,7 @@ def test_extract_guid_with_plain_text(self):
306306
# Assert
307307
assert result == input_string
308308
assert error_message is not None
309-
assert "The value provided in <code>MONITORED_CONTENT_GUID</code> is not a valid GUID" in error_message
309+
assert "The value provided in <code>MONITORED_CONTENT</code> is not a valid GUID" in error_message
310310
assert "A valid GUID looks like: <code>1d97c1ff-e56c-4074-906f-cb3557685b75</code>" in error_message
311311
assert f"The provided value was: <code>{input_string}</code>" in error_message
312312
assert "Please update your environment variable with a valid GUID or a URL containing a GUID" in error_message
@@ -802,10 +802,10 @@ def test_scenario_no_canary_guid_env_var(self, mock_client, state):
802802
Expected: If scheduled, DOES NOT send an email
803803
"""
804804
# Clear environment variable if it exists
805-
clear_env_var("MONITORED_CONTENT_GUID")
805+
clear_env_var("MONITORED_CONTENT")
806806

807807
# Execute - Try to get the env var
808-
result = get_env_var("MONITORED_CONTENT_GUID", state)
808+
result = get_env_var("MONITORED_CONTENT", state)
809809

810810
# Assert - It should be empty and show instructions
811811
assert result == ""

extensions/content-health-monitor/test_integration.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def clean_environment():
2323
os.environ['PYTHONPATH'] = original_env['PYTHONPATH']
2424

2525
# Explicitly ensure these variables are not set
26-
for var in ['MONITORED_CONTENT_GUID', 'VAR1', 'VAR2', 'TEST_VAR']:
26+
for var in ['MONITORED_CONTENT', 'VAR1', 'VAR2', 'TEST_VAR']:
2727
if var in os.environ:
2828
del os.environ[var]
2929

@@ -55,18 +55,18 @@ def test_get_env_var_missing_variable(clean_environment, state):
5555
This simulates the case that was causing errors in Connect.
5656
"""
5757
# Make sure the variable is not in environment
58-
if 'MONITORED_CONTENT_GUID' in os.environ:
59-
del os.environ['MONITORED_CONTENT_GUID']
58+
if 'MONITORED_CONTENT' in os.environ:
59+
del os.environ['MONITORED_CONTENT']
6060

6161
# Call the function that was failing
62-
value = content_health_utils.get_env_var('MONITORED_CONTENT_GUID', state)
62+
value = content_health_utils.get_env_var('MONITORED_CONTENT', state)
6363

6464
# Verify function behavior
6565
assert value == ""
6666
assert state.show_instructions is True
6767
assert len(state.instructions) == 1
6868
assert "Content Settings" in state.instructions[0]
69-
assert "<code>MONITORED_CONTENT_GUID</code>" in state.instructions[0]
69+
assert "<code>MONITORED_CONTENT</code>" in state.instructions[0]
7070

7171
def test_multiple_env_var_checks(clean_environment, state):
7272
"""
@@ -76,7 +76,7 @@ def test_multiple_env_var_checks(clean_environment, state):
7676
# Check several variables
7777
var1 = content_health_utils.get_env_var('VAR1', state)
7878
var2 = content_health_utils.get_env_var('VAR2', state)
79-
var3 = content_health_utils.get_env_var('MONITORED_CONTENT_GUID', state)
79+
var3 = content_health_utils.get_env_var('MONITORED_CONTENT', state)
8080

8181
# Verify function behavior
8282
assert var1 == ""

0 commit comments

Comments
 (0)