Skip to content

Commit

Permalink
Merge branch 'luqasz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
theGowda authored Dec 1, 2024
2 parents d9371c4 + d5e0aa9 commit c26da6d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.3.0
current_version = 3.3.1
commit = True
tag = True
tag_name = {new_version}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.3.1
----------

* Fix empty `select()` `=.proplist=` argument

3.3.0
----------

Expand Down
9 changes: 6 additions & 3 deletions librouteros/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ def where(self, *args: str):
return self

def __iter__(self) -> ResponseIter:
keys = ",".join(str(key) for key in self.keys)
keys = f"=.proplist={keys}"
cmd = str(self.path.join("print"))
return iter(self.api.rawCmd(cmd, keys, *self.query))
words = tuple(self.query)
if len(self.keys) > 0:
keys = ",".join(str(key) for key in self.keys)
keys = f"=.proplist={keys}"
words = (keys,) + words
return iter(self.api.rawCmd(cmd, *words))


def And(left: QueryGen, right: QueryGen, *rest: QueryGen) -> QueryGen:
Expand Down
38 changes: 19 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 = "librouteros"
version = "3.3.0"
version = "3.3.1"
description = "Python implementation of MikroTik RouterOS API"
authors = ["Łukasz Kostka <[email protected]>"]
license = "GPL-2.0-or-later"
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_where_chains_from_args(self):
assert self.query.query == (1, 2, 3, 4, 5)

@patch("librouteros.query.iter")
def test_iter_calls_api_rawCmd(self, iter_mock):
def test_iter_with_proplist(self, iter_mock):
self.query.keys = ("name", "disabled")
self.query.query = ("key1", "key2")
iter(self.query)
Expand All @@ -39,6 +39,17 @@ def test_iter_calls_api_rawCmd(self, iter_mock):
"key2",
)

@patch("librouteros.query.iter")
def test_iter_no_proplist(self, iter_mock):
self.query.keys = ()
self.query.query = ("key1", "key2")
iter(self.query)
self.query.api.rawCmd.assert_called_once_with(
str(self.query.path.join.return_value),
"key1",
"key2",
)


class Test_Key:
def setup_method(self):
Expand Down

0 comments on commit c26da6d

Please sign in to comment.