@ -16,7 +16,6 @@
import mock
from osc_lib . tests import utils
import six
# Load the plugin init module for the plugin list and show commands
from tripleoclient import exceptions
@ -33,9 +32,11 @@ class TestUpgrade(utils.TestCommand):
self . cmd . ansible_dir = ' /tmp '
self . ansible_playbook_cmd = " ansible-playbook "
@mock.patch ( ' tripleoclient.utils.prompt_user_for_confirmation ' ,
return_value = True )
@mock.patch ( ' tripleoclient.v1.tripleo_deploy.Deploy.take_action ' ,
autospec = True )
def test_take_action ( self , mock_deploy ):
def test_take_action ( self , mock_deploy , mock_confirm ):
verifylist = [
( ' local_ip ' , ' 127.0.0.1 ' ) ,
( ' templates ' , ' /tmp/thtroot ' ) ,
@ -61,12 +62,11 @@ class TestUpgrade(utils.TestCommand):
parsed_args . upgrade = True
mock_deploy . assert_called_with ( self . cmd , parsed_args )
@mock.patch ( ' tripleoclient.utils.prompt_user_for_confirmation ' ,
return_value = True )
@mock.patch ( ' tripleoclient.v1.tripleo_deploy.Deploy.take_action ' ,
autospec = True )
@mock.patch ( ' sys.stdin ' , spec = six . StringIO )
def test_take_action_prompt ( self , mock_stdin , mock_deploy ) :
mock_stdin . isatty . return_value = True
mock_stdin . readline . return_value = ' y '
def test_take_action_prompt ( self , mock_deploy , mock_confirm ) :
parsed_args = self . check_parser ( self . cmd ,
[ ' --local-ip ' , ' 127.0.0.1 ' ,
' --templates ' , ' /tmp/thtroot ' ,
@ -83,12 +83,11 @@ class TestUpgrade(utils.TestCommand):
parsed_args . upgrade = True
mock_deploy . assert_called_with ( self . cmd , parsed_args )
@mock.patch ( ' tripleoclient.utils.prompt_user_for_confirmation ' ,
return_value = False )
@mock.patch ( ' tripleoclient.v1.tripleo_deploy.Deploy ' ,
autospec = True )
@mock.patch ( ' sys.stdin ' , spec = six . StringIO )
def test_take_action_prompt_no ( self , mock_stdin , mock_deploy ) :
mock_stdin . isatty . return_value = True
mock_stdin . readline . return_value = ' n '
def test_take_action_prompt_no ( self , mock_deploy , mock_confirm ) :
parsed_args = self . check_parser ( self . cmd ,
[ ' --local-ip ' , ' 127.0.0.1 ' ,
' --templates ' , ' /tmp/thtroot ' ,
@ -104,29 +103,4 @@ class TestUpgrade(utils.TestCommand):
parsed_args . upgrade = True
self . assertRaises ( exceptions . UndercloudUpgradeNotConfirmed ,
self . cmd . take_action , parsed_args )
mock_stdin . readline . assert_called_with ( )
mock_deploy . assert_not_called ( )
@mock.patch ( ' tripleoclient.v1.tripleo_deploy.Deploy ' ,
autospec = True )
@mock.patch ( ' sys.stdin ' , spec = six . StringIO )
def test_take_action_prompt_invalid_option ( self , mock_stdin , mock_deploy ) :
mock_stdin . isatty . return_value = True
mock_stdin . readline . return_value = ' Dontwant '
parsed_args = self . check_parser ( self . cmd ,
[ ' --local-ip ' , ' 127.0.0.1 ' ,
' --templates ' , ' /tmp/thtroot ' ,
' --stack ' , ' undercloud ' ,
' --output-dir ' , ' /my ' ,
' -e ' , ' /tmp/thtroot/puppet/foo.yaml ' ,
' -e ' , ' /tmp/thtroot//docker/bar.yaml ' ,
' -e ' , ' /tmp/thtroot42/notouch.yaml ' ,
' -e ' , ' ~/custom.yaml ' ,
' -e ' , ' something.yaml ' ,
' -e ' , ' ../../../outside.yaml ' ] , [ ] )
parsed_args . standlone = True
parsed_args . upgrade = True
self . assertRaises ( exceptions . UndercloudUpgradeNotConfirmed ,
self . cmd . take_action , parsed_args )
mock_stdin . readline . assert_called_with ( )
mock_deploy . assert_not_called ( )