mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	Add apt_list_upgradable rule (#732)
This helps you run `apt list --upgradable` after `apt update`, as it suggests.
This commit is contained in:
		
				
					committed by
					
						 Vladimir Iakovlev
						Vladimir Iakovlev
					
				
			
			
				
	
			
			
			
						parent
						
							97123dbf73
						
					
				
				
					commit
					d582159670
				
			
							
								
								
									
										72
									
								
								tests/rules/test_apt_list_upgradable.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								tests/rules/test_apt_list_upgradable.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| import pytest | ||||
| from thefuck.rules.apt_list_upgradable import get_new_command, match | ||||
| from thefuck.types import Command | ||||
|  | ||||
| match_output = ''' | ||||
| Hit:1 http://us.archive.ubuntu.com/ubuntu zesty InRelease | ||||
| Hit:2 http://us.archive.ubuntu.com/ubuntu zesty-updates InRelease | ||||
| Get:3 http://us.archive.ubuntu.com/ubuntu zesty-backports InRelease [89.2 kB] | ||||
| Hit:4 http://security.ubuntu.com/ubuntu zesty-security InRelease | ||||
| Hit:5 http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu zesty InRelease | ||||
| Hit:6 https://download.docker.com/linux/ubuntu zesty InRelease | ||||
| Hit:7 https://cli-assets.heroku.com/branches/stable/apt ./ InRelease | ||||
| Fetched 89.2 kB in 0s (122 kB/s) | ||||
| Reading package lists... Done | ||||
| Building dependency tree | ||||
| Reading state information... Done | ||||
| 8 packages can be upgraded. Run 'apt list --upgradable' to see them. | ||||
| ''' | ||||
|  | ||||
| no_match_output = ''' | ||||
| Hit:1 http://us.archive.ubuntu.com/ubuntu zesty InRelease | ||||
| Get:2 http://us.archive.ubuntu.com/ubuntu zesty-updates InRelease [89.2 kB] | ||||
| Get:3 http://us.archive.ubuntu.com/ubuntu zesty-backports InRelease [89.2 kB] | ||||
| Get:4 http://security.ubuntu.com/ubuntu zesty-security InRelease [89.2 kB] | ||||
| Hit:5 https://cli-assets.heroku.com/branches/stable/apt ./ InRelease | ||||
| Hit:6 http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu zesty InRelease | ||||
| Hit:7 https://download.docker.com/linux/ubuntu zesty InRelease | ||||
| Get:8 http://us.archive.ubuntu.com/ubuntu zesty-updates/main i386 Packages [232 kB] | ||||
| Get:9 http://us.archive.ubuntu.com/ubuntu zesty-updates/main amd64 Packages [235 kB] | ||||
| Get:10 http://us.archive.ubuntu.com/ubuntu zesty-updates/main amd64 DEP-11 Metadata [55.2 kB] | ||||
| Get:11 http://us.archive.ubuntu.com/ubuntu zesty-updates/main DEP-11 64x64 Icons [32.3 kB] | ||||
| Get:12 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe amd64 Packages [156 kB] | ||||
| Get:13 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe i386 Packages [156 kB] | ||||
| Get:14 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe amd64 DEP-11 Metadata [175 kB] | ||||
| Get:15 http://us.archive.ubuntu.com/ubuntu zesty-updates/universe DEP-11 64x64 Icons [253 kB] | ||||
| Get:16 http://us.archive.ubuntu.com/ubuntu zesty-updates/multiverse amd64 DEP-11 Metadata [5,840 B] | ||||
| Get:17 http://us.archive.ubuntu.com/ubuntu zesty-backports/universe amd64 DEP-11 Metadata [4,588 B] | ||||
| Get:18 http://security.ubuntu.com/ubuntu zesty-security/main amd64 DEP-11 Metadata [12.7 kB] | ||||
| Get:19 http://security.ubuntu.com/ubuntu zesty-security/main DEP-11 64x64 Icons [17.6 kB] | ||||
| Get:20 http://security.ubuntu.com/ubuntu zesty-security/universe amd64 DEP-11 Metadata [21.6 kB] | ||||
| Get:21 http://security.ubuntu.com/ubuntu zesty-security/universe DEP-11 64x64 Icons [47.7 kB] | ||||
| Get:22 http://security.ubuntu.com/ubuntu zesty-security/multiverse amd64 DEP-11 Metadata [208 B] | ||||
| Fetched 1,673 kB in 0s (1,716 kB/s) | ||||
| Reading package lists... Done | ||||
| Building dependency tree | ||||
| Reading state information... Done | ||||
| All packages are up to date. | ||||
| ''' | ||||
|  | ||||
|  | ||||
| def test_match(): | ||||
|     assert match(Command('sudo apt update', match_output)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command', [ | ||||
|     Command('apt-cache search foo', ''), | ||||
|     Command('aptitude search foo', ''), | ||||
|     Command('apt search foo', ''), | ||||
|     Command('apt-get install foo', ''), | ||||
|     Command('apt-get source foo', ''), | ||||
|     Command('apt-get clean', ''), | ||||
|     Command('apt-get remove', ''), | ||||
|     Command('apt-get update', ''), | ||||
|     Command('sudo apt update', no_match_output) | ||||
| ]) | ||||
| def test_not_match(command): | ||||
|     assert not match(command) | ||||
|  | ||||
|  | ||||
| def test_get_new_command(): | ||||
|     new_command = get_new_command(Command('sudo apt update', match_output)) | ||||
|     assert new_command == 'apt list --upgradable' | ||||
		Reference in New Issue
	
	Block a user