[jira] new feature added scrap_regex_from_issue + docs + example #1325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
`
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.