Skip to content

Commit

Permalink
Change: Remove hardcoded ignore_pagination from get_reports (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
y0urself committed Sep 1, 2022
1 parent 6dddf66 commit 9d81b73
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
6 changes: 5 additions & 1 deletion gvm/protocols/gmpv208/entities/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def get_reports(
filter_id: Optional[str] = None,
note_details: Optional[bool] = None,
override_details: Optional[bool] = None,
ignore_pagination: Optional[bool] = None,
details: Optional[bool] = None,
) -> Any:
"""Request a list of reports
Expand All @@ -117,6 +118,8 @@ def get_reports(
note_details: If notes are included, whether to include note details
override_details: If overrides are included, whether to include
override details
ignore_pagination: Whether to ignore the filter terms "first" and
"rows".
details: Whether to exclude results
Returns:
Expand All @@ -139,7 +142,8 @@ def get_reports(
if details is not None:
cmd.set_attribute("details", to_bool(details))

cmd.set_attribute("ignore_pagination", "1")
if ignore_pagination is not None:
cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination))

return self._send_xml_command(cmd)

Expand Down
26 changes: 10 additions & 16 deletions tests/protocols/gmpv208/entities/reports/test_get_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ class GmpGetReportsTestMixin:
def test_get_reports(self):
self.gmp.get_reports()

self.connection.send.has_been_called_with(
'<get_reports ignore_pagination="1"/>'
)
self.connection.send.has_been_called_with("<get_reports/>")

def test_get_reports_with_filter_string(self):
self.gmp.get_reports(filter_string="name=foo")
self.gmp.get_reports(filter_string="name=foo", ignore_pagination=1)

self.connection.send.has_been_called_with(
'<get_reports report_filter="name=foo" ignore_pagination="1"/>'
Expand All @@ -36,47 +34,43 @@ def test_get_reports_with_filter_id(self):
self.gmp.get_reports(filter_id="f1")

self.connection.send.has_been_called_with(
'<get_reports report_filt_id="f1" ignore_pagination="1"/>'
'<get_reports report_filt_id="f1"/>'
)

def test_get_reports_without_note_details(self):
self.gmp.get_reports(note_details=False)

self.connection.send.has_been_called_with(
'<get_reports note_details="0" ignore_pagination="1"/>'
'<get_reports note_details="0"/>'
)

def test_get_reports_with_note_details(self):
self.gmp.get_reports(note_details=True)
self.gmp.get_reports(note_details=True, ignore_pagination=False)

self.connection.send.has_been_called_with(
'<get_reports note_details="1" ignore_pagination="1"/>'
'<get_reports note_details="1" ignore_pagination="0"/>'
)

def test_get_reports_without_override_details(self):
self.gmp.get_reports(override_details=False)

self.connection.send.has_been_called_with(
'<get_reports override_details="0" ignore_pagination="1"/>'
'<get_reports override_details="0"/>'
)

def test_get_reports_with_override_details(self):
self.gmp.get_reports(override_details=True)

self.connection.send.has_been_called_with(
'<get_reports override_details="1" ignore_pagination="1"/>'
'<get_reports override_details="1"/>'
)

def test_get_reports_with_details(self):
self.gmp.get_reports(details=True)

self.connection.send.has_been_called_with(
'<get_reports details="1" ignore_pagination="1"/>'
)
self.connection.send.has_been_called_with('<get_reports details="1"/>')

def test_get_reports_without_details(self):
self.gmp.get_reports(details=False)

self.connection.send.has_been_called_with(
'<get_reports details="0" ignore_pagination="1"/>'
)
self.connection.send.has_been_called_with('<get_reports details="0"/>')

0 comments on commit 9d81b73

Please sign in to comment.