Skip to content

Commit

Permalink
Fix import issue with resolve type
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric05 committed Jan 1, 2025
1 parent f6a5f31 commit 42bfc20
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dotextensions/server/handlers/basic_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
35 changes: 28 additions & 7 deletions test/extensions/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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,
)
)
Expand All @@ -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:
Expand Down

0 comments on commit 42bfc20

Please sign in to comment.