Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed May 13, 2020
1 parent 6869011 commit b83973f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_scan_and_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,36 @@ def test_sort_host_finished(self):
rounded_progress = int(daemon.calculate_progress(scan_id))
self.assertEqual(rounded_progress, 66)

def test_calculate_progress_without_current_hosts(self):
daemon = DummyWrapper([])

fs = FakeStream()
daemon.handle_command(
'<start_scan parallel="2">'
'<scanner_params />'
'<targets><target>'
'<hosts>localhost1, localhost2, localhost3, localhost4</hosts>'
'<ports>22</ports>'
'</target></targets>'
'</start_scan>',
fs,
)
response = fs.get_response()

scan_id = response.findtext('id')
daemon.set_scan_host_progress(scan_id)
daemon.set_scan_host_progress(scan_id, 'localhost3', -1)
daemon.set_scan_host_progress(scan_id, 'localhost4', 100)

daemon.sort_host_finished(scan_id, ['localhost3', 'localhost4'])

float_progress = daemon.calculate_progress(scan_id)
self.assertEqual(int(float_progress), 33)

daemon.scan_collection.set_progress(scan_id, float_progress)
progress = daemon.get_scan_progress(scan_id)
self.assertEqual(progress, 33)

def test_get_scan_progress_xml(self):
daemon = DummyWrapper([])

Expand Down

0 comments on commit b83973f

Please sign in to comment.