]> Nutra Git (v2) - nutratech/cli.git/commitdiff
fix test mock with _list_bugs_unsubmitted
authorShane Jaroch <chown_tee@proton.me>
Fri, 19 Apr 2024 17:43:56 +0000 (13:43 -0400)
committerShane Jaroch <chown_tee@proton.me>
Fri, 19 Apr 2024 17:43:56 +0000 (13:43 -0400)
    wasn't getting called now due to loss of happy path

tests/services/test_bug.py

index 646bfe1bbc6ab4cb4fdea7be83fc47110adf53f1..90a222ff9e85221ea9e552ad5911fea6199d7ea7 100644 (file)
@@ -44,6 +44,18 @@ class TestBug(unittest.TestCase):
         assert len(_bug.values()) >= 0
         assert len(_bug.keys()) == 1
 
+    @patch("ntclient.services.api.cache_mirrors", return_value="https://someurl.com")
+    @patch(
+        "ntclient.services.api.ApiClient.post",
+        return_value=MagicMock(status_code=201),
+    )
+    @patch("ntclient.services.bugs.sql_nt", return_value=([], [], [], []))
+    # pylint: disable=unused-argument
+    def test_bug_report(self, *args: MagicMock) -> None:
+        """Tests the functions for submitting bugs"""
+        result = bugs.submit_bugs()
+        assert isinstance(result, int)
+
     @patch("ntclient.services.api.cache_mirrors", return_value="https://someurl.com")
     @patch(
         "ntclient.services.api.ApiClient.post",
@@ -52,9 +64,10 @@ class TestBug(unittest.TestCase):
     @patch("ntclient.services.bugs._list_bugs_unsubmitted", return_value=[{"id": 1}])
     @patch("ntclient.services.bugs.sql_nt")
     # pylint: disable=unused-argument
-    def test_bug_report(self, *args: MagicMock) -> None:
+    def test_bug_report_with_unsubmitted(self, *args: MagicMock) -> None:
         """Tests the functions for submitting bugs"""
-        bugs.submit_bugs()
+        result = bugs.submit_bugs()
+        assert isinstance(result, int)
 
     @patch("ntclient.services.api.cache_mirrors", return_value="https://someurl.com")
     @patch(
@@ -66,7 +79,8 @@ class TestBug(unittest.TestCase):
     # pylint: disable=unused-argument
     def test_bug_report_on_204_status(self, *args: MagicMock) -> None:
         """Tests the functions for submitting bugs"""
-        bugs.submit_bugs()
+        result = bugs.submit_bugs()
+        assert result == 1
 
     @patch("ntclient.services.api.cache_mirrors", return_value="https://someurl.com")
     @patch(