diff --git a/dotextensions/server/handlers/basic_handlers.py b/dotextensions/server/handlers/basic_handlers.py index a96ec0e..9c20d78 100644 --- a/dotextensions/server/handlers/basic_handlers.py +++ b/dotextensions/server/handlers/basic_handlers.py @@ -306,10 +306,10 @@ def get_resolved(self, command: Command) -> Result: filename = command.params.get('file') content = command.params.get('content') pos = command.params.get('position') - if filename: - model: MultidefHttp = dothttp_model.model_from_file(filename) - else: + if content: model: MultidefHttp = dothttp_model.model_from_str(content) + else: + model: MultidefHttp = dothttp_model.model_from_file(filename) type_dict = TypeFromPos.figure_n_get(model, pos) if "target" not in type_dict: command.params["target"] = 1 diff --git a/pyproject.toml b/pyproject.toml index f8e1fdb..2db7602 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dothttp-req" -version = "0.0.44a7" +version = "0.0.44a8" description = "Dothttp is Simple http client for testing and development" authors = ["Prasanth "] license = "MIT" diff --git a/test/extensions/test_commands.py b/test/extensions/test_commands.py index 0d0f4c3..b255aea 100644 --- a/test/extensions/test_commands.py +++ b/test/extensions/test_commands.py @@ -165,7 +165,6 @@ def test_hover_json_content(self): ) self.assertEquals(10800, result2.result["resolved"]) - def test_hover_import_content(self): resolve_handler = GetHoveredResolvedParamContentHandler() names_http_file = f"{command_dir}/names.http" @@ -189,7 +188,6 @@ def test_hover_import_content(self): expected = "https://req.dothttp.dev/ram" self.assertEquals(expected, result.result["resolved"]) - def test_hover_context_content(self): resolve_handler = GetHoveredResolvedParamContentHandler() contexts = ["""@name('test3') @@ -208,15 +206,14 @@ def test_hover_context_content(self): result = resolve_handler.run( Command( method=resolve_handler.name, - params={"content": content, "position": index, "contexts": contexts}, + params={"content": content, + "position": index, "contexts": contexts}, id=1, ) ) expected = "https://httpbin.org/get/ram" self.assertEquals(expected, result.result["resolved"]) - - def test_hover_context_with_no_target(self): resolve_handler = GetHoveredResolvedParamContentHandler() contexts = ["""@name('test3') @@ -242,7 +239,8 @@ def test_hover_context_with_no_target(self): result = resolve_handler.run( Command( method=resolve_handler.name, - params={"content": content, "position": index, "contexts": contexts}, + params={"content": content, + "position": index, "contexts": contexts}, id=1, ) ) @@ -253,13 +251,36 @@ def test_hover_context_with_no_target(self): result = resolve_handler.run( Command( method=resolve_handler.name, - params={"content": content, "position": index, "contexts": contexts}, + params={"content": content, + "position": index, "contexts": contexts}, id=1, ) ) expected = {"totalSeconds": 10800, "rama": "ranga"} self.assertEquals(expected, result.result["resolved"]) + def test_hover_import_relative_content(self): + resolve_handler = GetHoveredResolvedParamContentHandler() + content = """import "./names.http"; + var numOfHours = 3; + var numOfSeconds = (numOfHours * 60 * 60); + @name("my-test"): "test3" + POST "/ram" + json({ + "totalSeconds" : {{numOfSeconds}} + }) + """ + index = content.find("ram") + result = resolve_handler.run( + Command( + method=resolve_handler.name, + params={"content": content, "position": index, + "file": f"{command_dir}/names.hnbk"}, + id=1, + ) + ) + expected = "https://req.dothttp.dev/ram" + class FileExecute(TestBase): def setUp(self) -> None: