)
bug_parser.set_defaults(func=parser_funcs.bugs_list)
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ # Simulate (bug)
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ bug_simulate_parser = bug_subparser.add_parser(
+ "simulate", help="simulate a bug (for testing purposes)"
+ )
+ bug_simulate_parser.set_defaults(func=parser_funcs.bug_simulate)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Report (bug)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
return 0, result
+# pylint: disable=unused-argument
+def bug_simulate(args: argparse.Namespace) -> tuple:
+ """Simulate a bug report"""
+ ntclient.services.bugs.simulate_bug()
+ return 0, None
+
+
def bugs_list(args: argparse.Namespace) -> tuple:
- """List bug reports that have een saved"""
+ """List bug reports that have been saved"""
_bugs_list = ntclient.services.bugs.list_bugs()
n_bugs_total = len(_bugs_list)
n_bugs_unsubmitted = len([x for x in _bugs_list if not bool(x[-1])])
return sql_bugs
+def simulate_bug() -> None:
+ """Simulate bug"""
+ raise NotImplementedError("This service intentionally raises an error, for testing")
+
+
def submit_bugs() -> int:
"""Submit bug reports to developer, return n_submitted."""
--- /dev/null
+# -*- coding: utf-8 -*-
+"""
+Created on Sun Feb 25 16:18:08 2024
+
+@author: shane
+"""
+import unittest
+
+import pytest
+
+from ntclient.__main__ import main
+from ntclient.services import bugs
+
+
+class TestBug(unittest.TestCase):
+ """Tests the bug service"""
+
+ def test_bug_simulate(self) -> None:
+ """Tests the functions for simulating a bug"""
+ with pytest.raises(NotImplementedError):
+ main(args=["--debug", "bug", "simulate"])
+
+ def test_bug_list(self) -> None:
+ """Tests the functions for listing bugs"""
+ bugs.list_bugs()
+
+ @unittest.expectedFailure
+ @pytest.mark.xfail(reason="Work in progress, need to get mocks working")
+ def test_bug_report(self) -> None:
+ """Tests the functions for submitting bugs"""
+ bugs.submit_bugs()
from ntclient.persistence.sql.usda import funcs as usda_funcs
from ntclient.persistence.sql.usda import sql as _usda_sql
from ntclient.persistence.sql.usda import usda_ver
-from ntclient.services import bugs, init, usda
+from ntclient.services import init, usda
from ntclient.services.recipe import RECIPE_HOME
from ntclient.utils import CLI_CONFIG
from ntclient.utils.exceptions import SqlInvalidVersionError
_food_amts={1001: 100}, _food_analyses=analysis, _nutrients=nutrients
)
assert output
-
- @unittest.expectedFailure
- @pytest.mark.xfail(reason="Work in progress, need to get mocks working")
- def test_1000_bugs(self):
- """Tests the functions for listing and submitting bugs"""
- bugs.list_bugs()
- # TODO: this should be mocked
- bugs.submit_bugs()