Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jira] new feature added scrap_regex_from_issue + docs + example #1325

Merged
merged 4 commits into from
Feb 1, 2024

Conversation

gkowalc
Copy link
Contributor

@gkowalc gkowalc commented Jan 31, 2024

  • Added new method to jira api scrap_regex_from_issue.
  • This method takes issue_id as an input + specified regex and returns all regex matches found in issue comments and descriptions.
  • Commits also includes docs + examples.
  • have tried to cover this feature with unit test but I didn't manage to make use of mockup files when using method patching:

`
try:
from unittest.mock import patch, MagicMock
except ImportError:
from mock import patch
def test_scrap_regex_from_issue(self):
regex = r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[?.]?){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
mock_without_comments = "< saved output from api1>"
mock_with_comments = "< saved output from api2>"
with patch("atlassian.Jira.get_issue") as mock_get_tables:
mock_get_tables.return_value = mock_without_comments
result = self.jira.scrap_regex_from_issue("REGEX-123", regex)
self.assertEqual(result, ["1.1.1.1", "11.1.1.3", "255.255.255.255"])
mock_get_tables.return_value = mock_with_comments
result = self.jira.scrap_regex_from_issue("REGEX-123", regex)
self.assertEqual(result, ["1.1.1.1", "11.1.1.3", "255.255.255.255", "222.41.32.111", "77.123.123.123"])

`

above code works fine with the unit tests (when mockup output assigned to the variable in the file), but when I added my mockup files to responses folder (next to "FOO-123" issue) I wasn't able to use mock within patch function.
To sum up, my PR doesn't include unit tests at this point, unless you are ok with including the mocked output directly into the test case scenario.

@gonchik gonchik merged commit a100d4f into atlassian-api:master Feb 1, 2024
10 checks passed
@gonchik
Copy link
Member

gonchik commented Feb 1, 2024

@gkowalc thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants