From 92ee051d2d4fc0220f8996be3c47365ee9b67ae9 Mon Sep 17 00:00:00 2001
From: idealbuq <iryna.dealbuquerquesilva@cea.fr>
Date: Wed, 2 Oct 2024 08:10:39 +0000
Subject: [PATCH] Corrected error in test_show_graphview by adding JSON suffix
 to temp file and added typehint for json_path in show_graphview.py

---
 aidge_core/show_graphview.py                 | 4 ++--
 aidge_core/unit_tests/test_show_graphview.py | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/aidge_core/show_graphview.py b/aidge_core/show_graphview.py
index ee7908b12..b8521d2c0 100644
--- a/aidge_core/show_graphview.py
+++ b/aidge_core/show_graphview.py
@@ -177,14 +177,14 @@ def _write_dict_json(graphview_dict : dict[str, int, float, bool, None], json_pa
 
     return None
     
-def gview_to_json(gview : aidge_core.GraphView, json_path : str, write_trainable_params_embed : bool = False, write_trainable_params_ext : bool = False, params_file_format : str = 'json') -> None:   
+def gview_to_json(gview : aidge_core.GraphView, json_path : Path, write_trainable_params_embed : bool = False, write_trainable_params_ext : bool = False, params_file_format : str = 'json') -> None:   
     """
     Generates the description for a GraphView in the JSON format.
     
     :param graph: A GraphView of Aidge.
     :type graph: aidge_core.GraphView
     :param json_path: Path to write JSON file.
-    :type json_path: str
+    :type json_path: Path
     :param write_trainable_params_embed: Whether or not to write the eventual trainable parameters of the Nodes in the same file as the dict (embed). 
     :type write_trainable_params_embed: bool, optional
     :param write_trainable_params_ext: Whether or not to write the eventual trainable parameters of the Nodes in an external file. 
diff --git a/aidge_core/unit_tests/test_show_graphview.py b/aidge_core/unit_tests/test_show_graphview.py
index 585473012..4c68e93e3 100644
--- a/aidge_core/unit_tests/test_show_graphview.py
+++ b/aidge_core/unit_tests/test_show_graphview.py
@@ -3,6 +3,7 @@ import tempfile
 import unittest
 import builtins
 import aidge_core
+from pathlib import Path
 from aidge_core.show_graphview import gview_to_json
 
 def create_gview():
@@ -64,9 +65,9 @@ class test_show_gview(unittest.TestCase):
         gview = create_gview()
 
         # Create temporary file to store JSON model description             
-        model_description_file = tempfile.NamedTemporaryFile(mode="w+")
+        model_description_file = tempfile.NamedTemporaryFile(mode="w+", suffix='.json')
 
-        gview_to_json(gview, model_description_file.name)
+        gview_to_json(gview, Path(model_description_file.name))
 
         # Load JSON
         with open(model_description_file.name, 'r') as fp:
-- 
GitLab