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.
Files changed (25) hide show
  1. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/PKG-INFO +1 -1
  2. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/setup.cfg +1 -1
  3. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/setup.py +1 -1
  4. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/__init__.py +1 -1
  5. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/bug_catcher.py +1 -1
  6. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/jira.py +3 -4
  7. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/PKG-INFO +1 -1
  8. t_bug_catcher-0.2.3/tests/test_t_bug_catcher.py +72 -0
  9. t_bug_catcher-0.2.2/tests/test_t_bug_catcher.py +0 -10
  10. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/MANIFEST.in +0 -0
  11. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/README.rst +0 -0
  12. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/pyproject.toml +0 -0
  13. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/requirements.txt +0 -0
  14. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/bug_snag.py +0 -0
  15. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/config.py +0 -0
  16. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/exceptions.py +0 -0
  17. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/utils/__init__.py +0 -0
  18. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/utils/common.py +0 -0
  19. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/utils/logger.py +0 -0
  20. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher/workitems.py +0 -0
  21. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
  22. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
  23. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/not-zip-safe +0 -0
  24. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/requires.txt +0 -0
  25. {t_bug_catcher-0.2.2 → t_bug_catcher-0.2.3}/t_bug_catcher.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.2.2
2
+ current_version = 0.2.3
3
3
  commit = True
4
4
  tag = False
5
5
 
@@ -26,7 +26,7 @@ setup(
26
26
  packages=find_packages(include=["t_bug_catcher", "t_bug_catcher.*"]),
27
27
  test_suite="tests",
28
28
  url="https://www.thoughtful.ai/",
29
- version="0.2.2",
29
+ version="0.2.3",
30
30
  zip_safe=False,
31
31
  install_requires=install_requirements,
32
32
  )
@@ -3,7 +3,7 @@
3
3
  __author__ = """Thoughtful"""
4
4
  __email__ = "support@thoughtful.ai"
5
5
  # fmt: off
6
- __version__ = '0.2.2'
6
+ __version__ = '0.2.3'
7
7
  # fmt: on
8
8
 
9
9
  from .bug_catcher import (
@@ -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() != "to do":
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["to do"],
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", self._issue_types["task"]),
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -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()
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env python
2
- """Tests for `t_bug_catcher` package."""
3
-
4
-
5
- class TestTBugCatcher:
6
- """Smoke tests of the package."""
7
-
8
- def test_example(self):
9
- """Smoke test."""
10
- assert True
File without changes
File without changes