Add missing TestWorkflowSecurity and TestEdgeCases classes to iteration status emails workflow tests#177
Add missing TestWorkflowSecurity and TestEdgeCases classes to iteration status emails workflow tests#177
Conversation
…EdgeCases class Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
…_missing_dashboard Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the iteration status emails workflow test module to match the common workflow test structure expected by cross-file consistency tests.
Changes:
- Renamed
TestSecurityBestPracticestoTestWorkflowSecurityfor naming consistency across workflow test modules. - Added a
TestEdgeCasesclass with additional YAML/workflow edge-case checks.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread🚀 |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="tests/workflows/test_iteration_status_emails_workflow.py">
<violation number="1" location="tests/workflows/test_iteration_status_emails_workflow.py:393">
P2: The required key check treats only the literal "on" key as valid, but YAML may parse it as True (noted elsewhere in this file). This will cause false failures on valid workflows that use the boolean key.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…error handling Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
…k pattern Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
…pecific assertions Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
…sts and remove trailing whitespace Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Applied all changes from review #3703102668:
All 39 tests pass. Changes in commit 9a9acd3. |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="tests/workflows/test_iteration_status_emails_workflow.py">
<violation number="1" location="tests/workflows/test_iteration_status_emails_workflow.py:359">
P2: This test no longer detects duplicate job names because it checks uniqueness on a dict that has already discarded duplicates. Use a loader that raises on duplicate keys so the test still fails when the YAML contains duplicate job entries.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| assert leading_spaces % 2 == 0, \ | ||
| f"Line {i} has indentation that is not a multiple of 2 spaces" | ||
|
|
||
| def test_no_duplicate_job_names(self, jobs): |
There was a problem hiding this comment.
P2: This test no longer detects duplicate job names because it checks uniqueness on a dict that has already discarded duplicates. Use a loader that raises on duplicate keys so the test still fails when the YAML contains duplicate job entries.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/workflows/test_iteration_status_emails_workflow.py, line 359:
<comment>This test no longer detects duplicate job names because it checks uniqueness on a dict that has already discarded duplicates. Use a loader that raises on duplicate keys so the test still fails when the YAML contains duplicate job entries.</comment>
<file context>
@@ -347,26 +355,11 @@ def test_consistent_indentation(self, workflow_raw):
- # Parsing with UniqueKeyLoader will raise if any duplicate keys are present in the YAML.
- yaml.load(workflow_raw, Loader=UniqueKeyLoader)
+
+ def test_no_duplicate_job_names(self, jobs):
+ """Test that there are no duplicate job names."""
+ job_names = list(jobs.keys())
</file context>
|
@copilot apply changes based on the comments in this thread |
…ys() as requested Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
All changes from review thread #3703096165 have been applied. The implementation now uses
Applied the requested change to use
The issue was clarified in comment 2724788844. Changed the implementation to use |
This comment has been minimized.
This comment has been minimized.
| def test_no_duplicate_step_ids(self, workflow_content): | ||
| """Test that step IDs are unique within each job.""" | ||
| jobs = workflow_content.get('jobs', {}) | ||
| for job_name, job_config in jobs.items(): | ||
| steps = job_config.get('steps', []) | ||
| step_ids = [s.get('id') for s in steps if 'id' in s] | ||
| assert len(step_ids) == len(set(step_ids)), \ | ||
| f"Duplicate step IDs in job '{job_name}'" |
There was a problem hiding this comment.
test_no_duplicate_step_ids assumes every step is a dict; if the YAML contains an empty step (None) or a non-mapping value, if 'id' in s will raise. Consider asserting isinstance(step, dict) (or filtering to dicts) before inspecting keys so the test fails cleanly on malformed steps.
| @pytest.fixture(scope='module') | ||
| def jobs(workflow_content): | ||
| """ | ||
| Module-scoped fixture for jobs configuration. | ||
| """ | ||
| return workflow_content.get('jobs', {}) |
There was a problem hiding this comment.
The new jobs fixture is not referenced anywhere in this module. Either remove it to avoid dead test code, or switch the edge-case tests to accept jobs and use it (matching the pattern in other workflow test modules).
|
|
||
| def test_no_duplicate_job_names(self, workflow_content): | ||
| """Test that there are no duplicate job names.""" | ||
| job_names = list(workflow_content['jobs'].keys()) |
There was a problem hiding this comment.
test_no_duplicate_job_names indexes workflow_content['jobs'], which will raise a KeyError (test error) if the YAML is missing the jobs key. Prefer asserting jobs exists first (or using the jobs fixture / workflow_content.get('jobs')) so the test fails with a clear assertion message instead of erroring.
| job_names = list(workflow_content['jobs'].keys()) | |
| jobs = workflow_content.get('jobs') | |
| assert jobs is not None, "Workflow must define jobs" | |
| job_names = list(jobs.keys()) |
| missing = required_keys.difference(workflow_content.keys()) | ||
| assert not missing, f"Workflow is missing required top-level keys: {', '.join(sorted(missing))}" | ||
| # Verify trigger configuration exists (can be 'on' or True) | ||
| has_triggers = 'on' in workflow_content or True in workflow_content.keys() |
There was a problem hiding this comment.
has_triggers = 'on' in workflow_content or True in workflow_content.keys() can produce false positives because True == 1 in Python (so a numeric key 1 would satisfy it). Use the same approach as the other trigger tests (workflow_content.get('on') or workflow_content.get(True)) or check boolean keys with identity (e.g., any(k is True for k in keys)).
| has_triggers = 'on' in workflow_content or True in workflow_content.keys() | |
| has_triggers = ( | |
| 'on' in workflow_content | |
| or any(k is True for k in workflow_content.keys()) | |
| ) |
TestSecurityBestPracticestoTestWorkflowSecurityand addTestEdgeCasesclassTestSecurityBestPracticesclass toTestWorkflowSecurityTestEdgeCasesclass with appropriate test methodstest_workflow_handles_missing_dashboardto verify parse step checks for dashboard file and has failure handlertest_yaml_is_parseableto handle YAML 'on' key parsing as Truejobsfixture and simplifytest_no_duplicate_job_namesto match pattern in other workflow teststest_no_duplicate_job_namesto useworkflow_content['jobs'].keys()instead ofjobsfixture💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Summary by cubic
Renames TestSecurityBestPractices to TestWorkflowSecurity and adds a TestEdgeCases suite to cover YAML and workflow edge cases, per review on #171. No behavior changes; this aligns the refactor with feedback to unblock #171.
Written for commit 625eb2c. Summary will update on new commits.