t-bug-catcher 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/PKG-INFO +1 -1
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/setup.cfg +1 -1
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/setup.py +1 -1
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/__init__.py +1 -1
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/bug_catcher.py +1 -1
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/jira.py +3 -4
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/PKG-INFO +1 -1
- t_bug_catcher-0.2.3/tests/test_t_bug_catcher.py +72 -0
- t_bug_catcher-0.2.2/tests/test_t_bug_catcher.py +0 -10
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/MANIFEST.in +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/README.rst +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/pyproject.toml +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/requirements.txt +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/bug_snag.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/config.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/exceptions.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/utils/__init__.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/utils/common.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/utils/logger.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/workitems.py +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/not-zip-safe +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/requires.txt +0 -0
- {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/top_level.txt +0 -0
|
@@ -98,7 +98,7 @@ class BugCatcher:
|
|
|
98
98
|
def report_error(
|
|
99
99
|
self,
|
|
100
100
|
exception: Optional[Exception] = None,
|
|
101
|
-
description: Optional[str] =
|
|
101
|
+
description: Optional[str] = None,
|
|
102
102
|
metadata: Optional[dict] = None,
|
|
103
103
|
attachments: Optional[List] = None,
|
|
104
104
|
assignee: Optional[str] = None,
|
|
@@ -33,7 +33,6 @@ def retry_if_bad_request(func):
|
|
|
33
33
|
return func(*args, **kwargs)
|
|
34
34
|
except BadRequestError as ex:
|
|
35
35
|
nonlocal attempt
|
|
36
|
-
print(f"Bad request Attempt {attempt}...", "WARN")
|
|
37
36
|
attempt = attempt + 1 if attempt < tries else 1
|
|
38
37
|
raise ex
|
|
39
38
|
|
|
@@ -780,10 +779,10 @@ class Jira:
|
|
|
780
779
|
"""
|
|
781
780
|
issue_status = self.check_issue_status(existing_ticket["id"])
|
|
782
781
|
self._transition_types = self.__get_transtion_types(issue_id=existing_ticket["id"])
|
|
783
|
-
if issue_status.lower()
|
|
782
|
+
if issue_status.lower() not in ["to do", "open"]:
|
|
784
783
|
self.issue_transition(
|
|
785
784
|
ticket_id=existing_ticket["id"],
|
|
786
|
-
transition_id=self._transition_types
|
|
785
|
+
transition_id=self._transition_types.get("to do", "open"),
|
|
787
786
|
)
|
|
788
787
|
self.update_comment(
|
|
789
788
|
ticket_id=existing_ticket["id"],
|
|
@@ -844,7 +843,7 @@ class Jira:
|
|
|
844
843
|
summary=summary[:255].split("\n")[0],
|
|
845
844
|
description=description,
|
|
846
845
|
assignee=assignee_id,
|
|
847
|
-
issue_type=self._issue_types.get("bug"
|
|
846
|
+
issue_type=self._issue_types.get("bug") or self._issue_types.get("task", "support"),
|
|
848
847
|
labels=labels,
|
|
849
848
|
)
|
|
850
849
|
response = self.post_ticket(issue=issue)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import unittest
|
|
3
|
+
from unittest.mock import PropertyMock, patch
|
|
4
|
+
|
|
5
|
+
from t_bug_catcher.bug_catcher import BugCatcher
|
|
6
|
+
from t_bug_catcher.config import CONFIG
|
|
7
|
+
from t_bug_catcher.utils import logger
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestBugCatcher(unittest.TestCase):
|
|
11
|
+
"""TestBugCatcher class."""
|
|
12
|
+
|
|
13
|
+
def setUp(self):
|
|
14
|
+
"""Set up."""
|
|
15
|
+
self.bug_catcher = BugCatcher()
|
|
16
|
+
|
|
17
|
+
def test_report_error_with_local_environment(self):
|
|
18
|
+
"""Test report_error function."""
|
|
19
|
+
with patch.object(logger, "warning") as mock_warning:
|
|
20
|
+
self.bug_catcher.report_error()
|
|
21
|
+
mock_warning.assert_called_once_with("Reporting an error is not supported in local environment.")
|
|
22
|
+
|
|
23
|
+
@patch.object(CONFIG, "ENVIRONMENT", "robocloud")
|
|
24
|
+
def test_report_error_with_no_configurations(self):
|
|
25
|
+
"""Test report_error function."""
|
|
26
|
+
with patch.object(logger, "warning") as mock_warning:
|
|
27
|
+
self.bug_catcher.report_error()
|
|
28
|
+
mock_warning.assert_called_once_with(
|
|
29
|
+
"Jira and BugSnag are not configured. Please configure them before reporting an error."
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def test_jira_configure(self):
|
|
33
|
+
"""Test jira_configure function."""
|
|
34
|
+
self.bug_catcher.configure.jira(
|
|
35
|
+
login=os.getenv("JIRA_LOGIN"),
|
|
36
|
+
api_token=os.getenv("JIRA_API_TOKEN"),
|
|
37
|
+
project_key=os.getenv("JIRA_PROJECT_KEY"),
|
|
38
|
+
)
|
|
39
|
+
assert self.bug_catcher.configure.is_jira_configured
|
|
40
|
+
|
|
41
|
+
def test_bugsnag_configure(self):
|
|
42
|
+
"""Test bugsnag_configure function."""
|
|
43
|
+
self.bug_catcher.configure.bugsnag(api_key=os.getenv("BUGSNAG_API_KEY"))
|
|
44
|
+
assert self.bug_catcher.configure.is_bugsnag_configured
|
|
45
|
+
|
|
46
|
+
def test_attach_file(self):
|
|
47
|
+
"""Test attach_file function."""
|
|
48
|
+
ex = Exception("some error")
|
|
49
|
+
self.bug_catcher.attach_file_to_exception(exception=ex, attachment="test.txt")
|
|
50
|
+
assert hasattr(ex, "custom_attachments")
|
|
51
|
+
|
|
52
|
+
@patch.object(CONFIG, "ENVIRONMENT", "robocloud")
|
|
53
|
+
def test_report_error(self):
|
|
54
|
+
"""Test report_error function."""
|
|
55
|
+
with patch.object(
|
|
56
|
+
self.bug_catcher, "_BugCatcher__configurator", new_callable=PropertyMock
|
|
57
|
+
) as mock_configurator:
|
|
58
|
+
patch.object(mock_configurator, "is_jira_configured", return_value=True)
|
|
59
|
+
patch.object(mock_configurator, "is_bugsnag_configured", return_value=True)
|
|
60
|
+
try:
|
|
61
|
+
raise Exception("Test exception")
|
|
62
|
+
except Exception as ex:
|
|
63
|
+
with patch.object(logger, "warning") as mock_warning:
|
|
64
|
+
self.bug_catcher.report_error(exception=ex)
|
|
65
|
+
actual_call = mock_warning.call_args
|
|
66
|
+
warning_message = actual_call[0][0]
|
|
67
|
+
self.assertTrue(warning_message.startswith("Failed to create Jira issue due to"))
|
|
68
|
+
self.assertEqual(mock_warning.call_count, 1)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|