Пример #1
0
class UpdateProgressObservableTest(unittest.TestCase):
    def setUp(self) -> None:
        self.updateProgressObservable = UpdateProgressObservable()
        self.someObserver = MockObserver()
        self.anotherObserver = MockObserver()
        self.updateProgressObservable.attach(self.someObserver)
        self.updateProgressObservable.attach(self.anotherObserver)

    def test_start_notifiesAllObservers(self):
        self.assertFalse(self.someObserver.started)
        self.assertFalse(self.anotherObserver.started)
        self.updateProgressObservable.start()
        self.assertTrue(self.someObserver.started)
        self.assertTrue(self.anotherObserver.started)

    def test_finished_notifiesAllObservers(self):
        self.assertFalse(self.someObserver.finished)
        self.assertFalse(self.anotherObserver.finished)
        self.updateProgressObservable.finished()
        self.assertTrue(self.someObserver.finished)
        self.assertTrue(self.anotherObserver.finished)

    def test_updateProgress_notifiesAllObservers(self):
        self.assertEqual(0, self.someObserver.progress)
        self.assertEqual(0, self.anotherObserver.progress)
        self.updateProgressObservable.updateProgress(25)
        self.assertEqual(25, self.someObserver.progress)
        self.assertEqual(25, self.anotherObserver.progress)
Пример #2
0
    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)
Пример #3
0
    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 = {}
Пример #4
0
 def setUp(self) -> None:
     self.updateProgressObservable = UpdateProgressObservable()
     self.someObserver = MockObserver()
     self.anotherObserver = MockObserver()
     self.updateProgressObservable.attach(self.someObserver)
     self.updateProgressObservable.attach(self.anotherObserver)