def initNmapImporter(self): updateProgressObservable = UpdateProgressObservable() updateProgressObserver = QtUpdateProgressObserver(ProgressWidget('Importing nmap..')) updateProgressObservable.attach(updateProgressObserver) self.nmapImporter = NmapImporter(updateProgressObservable, self.logic.activeProject.repositoryContainer.hostRepository) self.nmapImporter.done.connect(self.importFinished) self.nmapImporter.schedule.connect(self.scheduler) # run automated attacks self.nmapImporter.log.connect(self.view.ui.LogOutputTextView.append)
def __init__(self, view, logic): self.logic = logic self.view = view self.view.setController(self) self.view.startOnce() self.view.startConnections() self.loadSettings( ) # creation of context menu actions from settings file and set up of various settings updateProgressObservable = UpdateProgressObservable() updateProgressObserver = QtUpdateProgressObserver( self.view.importProgressWidget) updateProgressObservable.attach(updateProgressObserver) self.initNmapImporter(updateProgressObservable) self.initPythonImporter() self.initScreenshooter() self.initBrowserOpener() self.start() # initialisations (globals, etc) self.initTimers() self.processTimers = {} self.processMeasurements = {}
class QtUpdateProgressObserverTest(unittest.TestCase): @patch("ui.ancillaryDialog.ProgressWidget") @patch('utilities.stenoLogging.get_logger') def setUp(self, mockProgressWidget, mockLogging) -> None: from ui.observers.QtUpdateProgressObserver import QtUpdateProgressObserver self.mockProgressWidget = mockProgressWidget self.qtUpdateProgressObserver = QtUpdateProgressObserver( self.mockProgressWidget) def test_onStart_callsShowOnProgressWidget(self): self.qtUpdateProgressObserver.onStart() self.mockProgressWidget.show.assert_called_once() def test_onFinished_callsHideOnProgressWidget(self): self.qtUpdateProgressObserver.onFinished() self.mockProgressWidget.hide.assert_called_once() def test_onProgressUpdate_callsSetProgressAndShow(self): self.qtUpdateProgressObserver.onProgressUpdate(25) self.mockProgressWidget.setProgress.assert_called_once_with(25) self.mockProgressWidget.show.assert_called_once()
def setUp(self, mockProgressWidget, mockLogging) -> None: from ui.observers.QtUpdateProgressObserver import QtUpdateProgressObserver self.mockProgressWidget = mockProgressWidget self.qtUpdateProgressObserver = QtUpdateProgressObserver( self.mockProgressWidget)