def test_scan_when_arch(self): # Prepare data and mocks with patch('platform.linux_distribution', lambda: ('arch', None, None)): update = Update(None) update.scan_arch = MagicMock(return_value=(ScanStatus.success, 'message')) # Run test scenario result = update.scan() # Assertions self.assertEqual(result, (ScanStatus.success, 'message')) update.scan_arch.assert_called_once_with()
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([])
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([])
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([])
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([])