Closed 3tractorrides closed 8 months ago
e2786efbf1
)[!TIP] I can email you next time I complete a pull request if you set up your email here!
Here are the GitHub Actions logs prior to making any changes:
518f031
Checking test_main.py for syntax errors... ✅ test_main.py has no syntax errors!
1/1 ✓Checking test_main.py for syntax errors... ✅ test_main.py has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
test_main.py
✓ https://github.com/3tractorrides/release-notes-formatter/commit/c2b470774881339870a1714e0d82158916fc272b Edit
Modify test_main.py with contents:
• Add a new test method within the `TestFormatTicketNumberList` class to test the scenario where the input string does not contain a ticket number. The input string should be a string without a ticket number, the base URL can be any valid URL, and the expected output should be the same as the input string since there is no ticket number to format.
• Add another test method to test the scenario where the ticket number in the input string is not in the expected format. The input string should contain a ticket number that is not preceded by "- AB#" or "- AB-", the base URL can be any valid URL, and the expected output should be the same as the input string since the ticket number is not in a format that can be recognized and formatted.
• Add a third test method to test the scenario where the base URL is not a valid URL. The input string can be any string with a valid ticket number, the base URL should be an invalid URL, and the expected output should be the same as the input string since the base URL is not valid and cannot be used to format the ticket number.
--- +++ @@ -3,6 +3,30 @@ from main import format_ticket_number_list, build_release_item_text class TestFormatTicketNumberList(unittest.TestCase): + + def test_invalid_base_url(self): + input_string = "- AB#1234 - context with a ticket number." + base_url = 'invalid-url' + expected_output = input_string + + transformed_content = format_ticket_number_list(re.search(r'(?<=- )AB[#-]?(\d+)', input_string), base_url) + self.assertEqual(transformed_content, expected_output) + + def test_ticket_number_in_unexpected_format(self): + input_string = "This string has ticket 1234 not in expected format." + base_url = 'https://dev.azure.com/valid-url/' + expected_output = input_string + + transformed_content = format_ticket_number_list(re.search(r'(?<=- )AB[#-]?(\d+)', input_string), base_url) + self.assertEqual(transformed_content, expected_output) + + def test_input_without_ticket_number(self): + input_string = "This is a string without a ticket number." + base_url = 'https://dev.azure.com/valid-url/' + expected_output = input_string + + transformed_content = format_ticket_number_list(re.search(r'(?<=- )AB[#-]?(\d+)', input_string), base_url) + self.assertEqual(transformed_content, expected_output) def test_format_ticket_number_list(self): input_string = "- AB#1234 - some context about this pr" base_url = 'https://dev.azure.com/parallax-app/Parallax%202023/_workitems/edit/'
test_main.py
✓ Edit
Check test_main.py with contents:
Ran GitHub Actions for c2b470774881339870a1714e0d82158916fc272b:
test_main.py
✓ https://github.com/3tractorrides/release-notes-formatter/commit/da6d2944b42cc15ffe6aa35f6170538d6a36538f Edit
Modify test_main.py with contents:
• Add a new test method within the `TestBuildReleaseItemText` class to test the scenario where the input string does not contain a ticket number. The input string should be a string without a ticket number, the base URL can be any valid URL, and the expected output should be the same as the input string since there is no ticket number to format.
• Add another test method to test the scenario where the ticket number in the input string is not in the expected format. The input string should contain a ticket number that is not preceded by "- AB#" or "- AB-", the base URL can be any valid URL, and the expected output should be the same as the input string since the ticket number is not in a format that can be recognized and formatted.
• Add a third test method to test the scenario where the base URL is not a valid URL. The input string can be any string with a valid ticket number, the base URL should be an invalid URL, and the expected output should be the same as the input string since the base URL is not valid and cannot be used to format the ticket number.
--- +++ @@ -3,6 +3,30 @@ from main import format_ticket_number_list, build_release_item_text class TestFormatTicketNumberList(unittest.TestCase): + + def test_invalid_base_url(self): + input_string = "- AB#1234 - context with a ticket number." + base_url = 'invalid-url' + expected_output = input_string + + transformed_content = format_ticket_number_list(re.search(r'(?<=- )AB[#-]?(\d+)', input_string), base_url) + self.assertEqual(transformed_content, expected_output) + + def test_ticket_number_in_unexpected_format(self): + input_string = "This string has ticket 1234 not in expected format." + base_url = 'https://dev.azure.com/valid-url/' + expected_output = input_string + + transformed_content = format_ticket_number_list(re.search(r'(?<=- )AB[#-]?(\d+)', input_string), base_url) + self.assertEqual(transformed_content, expected_output) + + def test_input_without_ticket_number(self): + input_string = "This is a string without a ticket number." + base_url = 'https://dev.azure.com/valid-url/' + expected_output = input_string + + transformed_content = format_ticket_number_list(re.search(r'(?<=- )AB[#-]?(\d+)', input_string), base_url) + self.assertEqual(transformed_content, expected_output) def test_format_ticket_number_list(self): input_string = "- AB#1234 - some context about this pr" base_url = 'https://dev.azure.com/parallax-app/Parallax%202023/_workitems/edit/' @@ -76,6 +100,30 @@ transformed_content = build_release_item_text(input_string, base_url) self.assertEqual(transformed_content, expected_output) + def test_input_without_ticket_number(self): + input_string = "This is a string without a ticket number." + base_url = 'https://dev.azure.com/valid-url/' + expected_output = input_string + + transformed_content = build_release_item_text(input_string, base_url) + self.assertEqual(transformed_content, expected_output) + + def test_ticket_number_in_unexpected_format(self): + input_string = "Text with TICKET-1234 not formatted." + base_url = 'https://dev.azure.com/valid-url/' + expected_output = input_string + + transformed_content = build_release_item_text(input_string, base_url) + self.assertEqual(transformed_content, expected_output) + + def test_invalid_base_url(self): + input_string = "- AB#1234 - context that should not get formatted." + base_url = 'invalid-url' + expected_output = input_string + + transformed_content = build_release_item_text(input_string, base_url) + self.assertEqual(transformed_content, expected_output) + if __name__ == '__main__': unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromTestCase(TestFormatTicketNumberList)) unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromTestCase(TestBuildReleaseItemText))
test_main.py
✓ Edit
Check test_main.py with contents:
Ran GitHub Actions for da6d2944b42cc15ffe6aa35f6170538d6a36538f:
I have finished reviewing the code for completeness. I did not find errors for sweep/add_unhappy_path_variations_to_unit_test
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Details
Unit Tests: update tests within
test_main.py
to include un-happy scenarios, ie: cases where the methods don't receive appropriate or well formatted inputs.Checklist
- [X] Modify `test_main.py` ✓ https://github.com/3tractorrides/release-notes-formatter/commit/c2b470774881339870a1714e0d82158916fc272b [Edit](https://github.com/3tractorrides/release-notes-formatter/edit/sweep/add_unhappy_path_variations_to_unit_test/test_main.py#L5-L36) - [X] Running GitHub Actions for `test_main.py` ✓ [Edit](https://github.com/3tractorrides/release-notes-formatter/edit/sweep/add_unhappy_path_variations_to_unit_test/test_main.py#L5-L36) - [X] Modify `test_main.py` ✓ https://github.com/3tractorrides/release-notes-formatter/commit/da6d2944b42cc15ffe6aa35f6170538d6a36538f [Edit](https://github.com/3tractorrides/release-notes-formatter/edit/sweep/add_unhappy_path_variations_to_unit_test/test_main.py#L38-L77) - [X] Running GitHub Actions for `test_main.py` ✓ [Edit](https://github.com/3tractorrides/release-notes-formatter/edit/sweep/add_unhappy_path_variations_to_unit_test/test_main.py#L38-L77)