示例#1
0
    def test_scan_arch_when_last_update_date_not_found(self):
        # Prepare data and mocks
        with patch('builtins.open', mock_open()) as mock_file:
            config = {'update': {'warn_last_update_interval_days': '2'}}
            update = Update(config)
            update.get_pacman_last_update_date = MagicMock(return_value=None)

            # Run test scenario
            result = update.scan_arch()

            # Assertions
            self.assertEqual(result[0], ScanStatus.unknown)
            mock_file.assert_called_once_with('/var/log/pacman.log')
            update.get_pacman_last_update_date.assert_called_once_with([])
示例#2
0
    def test_scan_arch_when_is_newer(self):
        # Prepare data and mocks
        with patch('builtins.open', mock_open()) as mock_file:
            config = {'update': {'warn_last_update_interval_days': '2'}}
            update = Update(config)
            update.get_pacman_last_update_date = MagicMock(
                return_value=datetime.today() - timedelta(days=1))

            # Run test scenario
            result = update.scan_arch()

            # Assertions
            self.assertEqual(result[0], ScanStatus.success)
            mock_file.assert_called_once_with('/var/log/pacman.log')
            update.get_pacman_last_update_date.assert_called_once_with([])
示例#3
0
文件: test_update.py 项目: axper/lmap
    def test_scan_arch_when_last_update_date_not_found(self):
        # Prepare data and mocks
        with patch('builtins.open', mock_open()) as mock_file:
            config = {
                'update': {
                    'warn_last_update_interval_days': '2'
                }
            }
            update = Update(config)
            update.get_pacman_last_update_date = MagicMock(return_value=None)

            # Run test scenario
            result = update.scan_arch()

            # Assertions
            self.assertEqual(result[0], ScanStatus.unknown)
            mock_file.assert_called_once_with('/var/log/pacman.log')
            update.get_pacman_last_update_date.assert_called_once_with([])
示例#4
0
文件: test_update.py 项目: axper/lmap
    def test_scan_arch_when_is_newer(self):
        # Prepare data and mocks
        with patch('builtins.open', mock_open()) as mock_file:
            config = {
                'update': {
                    'warn_last_update_interval_days': '2'
                }
            }
            update = Update(config)
            update.get_pacman_last_update_date = MagicMock(return_value=datetime.today() - timedelta(days=1))

            # Run test scenario
            result = update.scan_arch()

            # Assertions
            self.assertEqual(result[0], ScanStatus.success)
            mock_file.assert_called_once_with('/var/log/pacman.log')
            update.get_pacman_last_update_date.assert_called_once_with([])