コード例 #1
0
    def test_result_store_src2(self):
        """Test ConnectResultStore."""
        result_store = ConnectResultStore(self.scan_task3)
        hosts = ['1.2.3.4', '1.2.3.5', '1.2.3.6']
        self.assertCountEqual(result_store.remaining_hosts(), hosts)
        self.assertEqual(result_store.scan_task.systems_count, 3)
        self.assertEqual(result_store.scan_task.systems_scanned, 0)
        self.assertEqual(result_store.scan_task.systems_failed, 0)

        host = hosts.pop()
        result_store.record_result(host, self.source2, self.cred,
                                   SystemConnectionResult.SUCCESS)

        self.assertCountEqual(result_store.remaining_hosts(), hosts)
        self.assertEqual(result_store.scan_task.systems_count, 3)
        self.assertEqual(result_store.scan_task.systems_scanned, 1)
        self.assertEqual(result_store.scan_task.systems_failed, 0)

        host = hosts.pop()
        # Check failure without cred
        result_store.record_result(host, self.source2, None,
                                   SystemConnectionResult.FAILED)
        self.assertCountEqual(result_store.remaining_hosts(), hosts)
        self.assertEqual(result_store.scan_task.systems_count, 3)
        self.assertEqual(result_store.scan_task.systems_scanned, 1)
        self.assertEqual(result_store.scan_task.systems_failed, 1)

        host = hosts.pop()
        # Check failure with cred
        result_store.record_result(host, self.source2, self.cred,
                                   SystemConnectionResult.FAILED)
        self.assertCountEqual(result_store.remaining_hosts(), hosts)
        self.assertEqual(result_store.scan_task.systems_count, 3)
        self.assertEqual(result_store.scan_task.systems_scanned, 1)
        self.assertEqual(result_store.scan_task.systems_failed, 2)
コード例 #2
0
    def test_result_store(self):
        """Test ConnectResultStore."""
        result_store = ConnectResultStore(self.scan_task)

        self.assertEqual(result_store.remaining_hosts(), ['1.2.3.4'])
        self.assertEqual(result_store.scan_task.systems_count, 1)
        self.assertEqual(result_store.scan_task.systems_scanned, 0)
        self.assertEqual(result_store.scan_task.systems_failed, 0)

        result_store.record_result('1.2.3.4', self.source, self.cred,
                                   SystemConnectionResult.SUCCESS)

        self.assertEqual(result_store.remaining_hosts(), [])
        self.assertEqual(result_store.scan_task.systems_count, 1)
        self.assertEqual(result_store.scan_task.systems_scanned, 1)
        self.assertEqual(result_store.scan_task.systems_failed, 0)