Skip to content

Commit caf1a04

Browse files
author
Anthony Ruhier
committed
Fix query in GET of mappers
Queries where sent in request body instead of parameters
1 parent 65418b4 commit caf1a04

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

netboxapi/mapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get(self, *args, **kwargs):
3737
else:
3838
route = self._route
3939

40-
new_mappers_dict = self.netbox_api.get(route, data=kwargs)
40+
new_mappers_dict = self.netbox_api.get(route, params=kwargs)
4141
if "results" in new_mappers_dict:
4242
new_mappers_dict = new_mappers_dict["results"]
4343

tests/test_mapper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ def test_get_submodel(self, mapper):
5454
for key, val in expected_attr["results"][0].items():
5555
assert getattr(submodel_mapper, key) == val
5656

57+
def test_get_query(self, mapper):
58+
url = self.get_mapper_url(mapper) + "?name=test"
59+
expected_attr = {
60+
"count": 1, "next": None, "previous": None,
61+
"results": [{"id": 1, "name": "test"}]
62+
}
63+
with requests_mock.Mocker() as m:
64+
m.register_uri("get", url, json=expected_attr)
65+
next(mapper.get(name="test"))
66+
5767
def test_post(self, mapper):
5868
url = self.get_mapper_url(mapper)
5969

0 commit comments

Comments
 (0)