Files
deb-python-dcos/cli/tests/unit/test_package_uninstall.py
benclarkwood 1254a2f2b5 package: Gate package uninstall with an interactive confirmaton.
Note: This change is a breaking change to the existing change of `package uninstall`
2017-06-22 09:17:14 -07:00

81 lines
1.9 KiB
Python

import dcoscli.package.main as package
import dcoscli.util as util
def test_confirm_uninstall_remove_all_fail_challenge():
real_read = util._read_response
def fake_read():
return "hello-world"
util._read_response = fake_read
result = package._confirm_uninstall('hello-world', True, '')
util._read_response = real_read
assert result is False
def test_confirm_uninstall_remove_all_pass_challenge():
real_read = util._read_response
def fake_read():
return "uninstall all hello-world"
util._read_response = fake_read
result = package._confirm_uninstall('hello-world', True, '')
util._read_response = real_read
assert result is True
def test_confirm_uninstall_app_id_fail_challenge():
real_read = util._read_response
def fake_read():
return "hello-world"
util._read_response = fake_read
result = package._confirm_uninstall('hello-world', False, 'goodbye')
util._read_response = real_read
assert result is False
def test_confirm_uninstall_app_id_pass_challenge():
real_read = util._read_response
def fake_read():
return "goodbye"
util._read_response = fake_read
result = package._confirm_uninstall('hello-world', False, 'goodbye')
util._read_response = real_read
assert result is True
def test_confirm_uninstall_default_fail_challenge():
real_read = util._read_response
def fake_read():
return "kafka"
util._read_response = fake_read
result = package._confirm_uninstall('hello-world', False, '')
util._read_response = real_read
assert result is False
def test_confirm_uninstall_default_pass_challenge():
real_read = util._read_response
def fake_read():
return "hello-world"
util._read_response = fake_read
result = package._confirm_uninstall('hello-world', False, '')
util._read_response = real_read
assert result is True