示例#1
0
文件: test_update.py 项目: axper/lmap
    def test_scan_when_debian(self):
        # Prepare data and mocks
        with patch('platform.linux_distribution', lambda: ('debian', None, None)):
            update = Update(None)
            update.scan_debian = MagicMock(return_value=(ScanStatus.success, 'message'))

            # Run test scenario
            result = update.scan()

            # Assertions
            self.assertEqual(result, (ScanStatus.success, 'message'))
            update.scan_debian.assert_called_once_with()
示例#2
0
    def test_scan_debian_when_last_update_date_not_found(self):
        # Prepare data and mocks
        config = {'update': {'warn_last_update_interval_days': '2'}}
        update = Update(config)
        update.get_apt_last_update_date = MagicMock(return_value=None)

        # Run test scenario
        result = update.scan_debian()

        # Assertions
        self.assertEqual(result[0], ScanStatus.unknown)
        update.get_apt_last_update_date.assert_called_once_with(
            '/var/lib/apt/periodic/update-success-stamp')
示例#3
0
    def test_scan_debian_when_is_newer(self):
        # Prepare data and mocks
        config = {'update': {'warn_last_update_interval_days': '2'}}
        update = Update(config)
        update.get_apt_last_update_date = MagicMock(
            return_value=datetime.today() - timedelta(days=1))

        # Run test scenario
        result = update.scan_debian()

        # Assertions
        self.assertEqual(result[0], ScanStatus.success)
        update.get_apt_last_update_date.assert_called_once_with(
            '/var/lib/apt/periodic/update-success-stamp')
示例#4
0
    def test_scan_when_debian(self):
        # Prepare data and mocks
        with patch('platform.linux_distribution', lambda:
                   ('debian', None, None)):
            update = Update(None)
            update.scan_debian = MagicMock(return_value=(ScanStatus.success,
                                                         'message'))

            # Run test scenario
            result = update.scan()

            # Assertions
            self.assertEqual(result, (ScanStatus.success, 'message'))
            update.scan_debian.assert_called_once_with()
示例#5
0
文件: test_update.py 项目: axper/lmap
    def test_scan_debian_when_last_update_date_not_found(self):
        # Prepare data and mocks
        config = {
            'update': {
                'warn_last_update_interval_days': '2'
            }
        }
        update = Update(config)
        update.get_apt_last_update_date = MagicMock(return_value=None)

        # Run test scenario
        result = update.scan_debian()

        # Assertions
        self.assertEqual(result[0], ScanStatus.unknown)
        update.get_apt_last_update_date.assert_called_once_with('/var/lib/apt/periodic/update-success-stamp')
示例#6
0
文件: test_update.py 项目: axper/lmap
    def test_scan_debian_when_is_newer(self):
        # Prepare data and mocks
        config = {
            'update': {
                'warn_last_update_interval_days': '2'
            }
        }
        update = Update(config)
        update.get_apt_last_update_date = MagicMock(return_value=datetime.today() - timedelta(days=1))

        # Run test scenario
        result = update.scan_debian()

        # Assertions
        self.assertEqual(result[0], ScanStatus.success)
        update.get_apt_last_update_date.assert_called_once_with('/var/lib/apt/periodic/update-success-stamp')