]> Nutra Git (v2) - nutratech/cli.git/commitdiff
test coverage
authorShane Jaroch <chown_tee@proton.me>
Sun, 25 Feb 2024 20:53:09 +0000 (15:53 -0500)
committerShane Jaroch <chown_tee@proton.me>
Sun, 25 Feb 2024 20:53:09 +0000 (15:53 -0500)
ntclient/core/nutprogbar.py
ntclient/services/analyze.py
setup.cfg
tests/test_cli.py

index 2448e45407eca8b3b77ffeee91d6748081c9ddee..d23a91dbe124d5a8910fd06b00cba913c7c08c3b 100644 (file)
@@ -8,7 +8,7 @@ from ntclient.utils import CLI_CONFIG
 def nutrient_progress_bars(
     _food_amts: Mapping[int, float],
     _food_analyses: list,
-    _nutrients: Mapping[int, list],
+    _nutrients: Mapping[int, tuple],
     # grams: float = 100,
     # width: int = 50,
 ) -> Mapping[int, float]:
@@ -57,7 +57,7 @@ def nutrient_progress_bars(
 
 
 def print_nutrient_bar(
-    _n_id: int, _amount: float, _nutrients: Mapping[int, list]
+    _n_id: int, _amount: float, _nutrients: Mapping[int, tuple]
 ) -> tuple:
     """Print a single color-coded nutrient bar"""
     nutrient = _nutrients[_n_id]
index c9969a496f1e837802b894795a0693719ba62c2a..6c9849c30841f29cd8a5d6d132d13601906b27bb 100644 (file)
@@ -44,13 +44,6 @@ def foods_analyze(food_ids: set, grams: float = 100) -> tuple:
     TODO: support -t (tabular/non-visual) output flag
     """
 
-    def print_header(header: str) -> None:
-        """Print a header for this method"""
-        print()
-        print("=========================")
-        print(header)
-        print("=========================")
-
     ##########################################################################
     # Get analysis
     ##########################################################################
@@ -198,7 +191,8 @@ def day_analyze(day_csv_paths: Sequence[str], rda_csv_path: str = str()) -> tupl
                 if CLI_CONFIG.debug:
                     substr = "{0} {1}".format(_rda, _nutrient[2]).ljust(12)
                     print("INJECT RDA: {0} -->  {1}".format(substr, _nutrient[4]))
-    nutrients = {int(x[0]): x for x in nutrients_lists}
+    nutrients = {int(x[0]): tuple(x) for x in nutrients_lists}
+    print(nutrients)
 
     # Analyze foods
     foods_analysis = {}
@@ -236,7 +230,9 @@ def day_analyze(day_csv_paths: Sequence[str], rda_csv_path: str = str()) -> tupl
 
 
 def day_format(
-    analysis: Mapping[int, float], nutrients: Mapping[int, list], buffer: int = 0
+    analysis: Mapping[int, float],
+    nutrients: Mapping[int, tuple],
+    buffer: int = 0,
 ) -> None:
     """Formats day analysis for printing to console"""
 
@@ -278,8 +274,8 @@ def day_format(
 
     # Nutrition detail report
     print_header("Nutrition detail report")
-    for n_id in analysis:
-        print_nutrient_bar(n_id, analysis[n_id], nutrients)
+    for nutr_id, nutr_val in analysis.items():
+        print_nutrient_bar(nutr_id, nutr_val, nutrients)
     # TODO: actually filter and show the number of filtered fields
     print(
         "work in progress...",
index 60eeed0751f3308fae2a635e012765db61f9abe0..377db12d01df7bdd410e8cb07c589e9b9147d4e3 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,7 +9,7 @@ command_line = -m pytest
 source = ntclient
 
 [coverage:report]
-fail_under = 85.00
+fail_under = 90.00
 precision = 2
 
 show_missing = True
index 1add411e29406fac591a38393cf8fe9df57ce893..e12fb5dc537f4d4014cd40c3a25ae08a3e3680eb 100644 (file)
@@ -290,6 +290,18 @@ class TestCli(unittest.TestCase):
             17.11,
         )
 
+        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        # Bug
+        # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        args = arg_parser.parse_args(args="bug".split())
+        code, result = args.func(args)
+        assert code == 0
+        assert isinstance(result, list)
+        args = arg_parser.parse_args(args="bug --show".split())
+        code, result = args.func(args)
+        assert code == 0
+        assert isinstance(result, list)
+
     def test_415_invalid_path_day_throws_error(self):
         """Ensures invalid path throws exception in `day` subcommand"""
         invalid_day_csv_path = os.path.join(
@@ -436,6 +448,8 @@ class TestCli(unittest.TestCase):
         )
         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()