-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --image-pull-policy option to zun create command
With the commit 2c6ad5a119b97bc127d7ad3945adfd805c3ce4ba, we can decide whether to pull the image from docker repos according to the image pull policy. Add policy support on client side. Change-Id: I37c4653670c630fabe79b8ed3927db133ac5d0b5 Depends-On: #If2715d7724fd5336fb25d380f125e1485ca302d0 Closes-bug: 1644072
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import mock | ||
|
||
from zunclient.tests.v1 import shell_test_base | ||
|
||
|
||
class ShellTest(shell_test_base.TestCommandLineArgument): | ||
|
||
@mock.patch('zunclient.v1.containers_shell._show_container') | ||
@mock.patch('zunclient.v1.containers.ContainerManager.create') | ||
def test_zun_container_create_success_with_pull_policy( | ||
self, mock_create, mock_show_container): | ||
mock_create.return_value = 'container-never' | ||
self._test_arg_success( | ||
'create --image x --image-pull-policy never') | ||
mock_show_container.assert_called_with('container-never') | ||
|
||
mock_create.return_value = 'container-always' | ||
self._test_arg_success( | ||
'create --image x --image-pull-policy always') | ||
mock_show_container.assert_called_with('container-always') | ||
|
||
mock_create.return_value = 'container-ifnotpresent' | ||
self._test_arg_success( | ||
'create --image x --image-pull-policy ifnotpresent') | ||
mock_show_container.assert_called_with('container-ifnotpresent') | ||
|
||
@mock.patch('zunclient.v1.containers_shell._show_container') | ||
@mock.patch('zunclient.v1.containers.ContainerManager.create') | ||
def test_zun_container_create_success_without_pull_policy( | ||
self, mock_create, mock_show_container): | ||
mock_create.return_value = 'container' | ||
self._test_arg_success('create --image x') | ||
mock_show_container.assert_called_once_with('container') | ||
|
||
@mock.patch('zunclient.v1.containers.ContainerManager.create') | ||
def test_zun_container_create_failure_with_wrong_pull_policy( | ||
self, mock_create): | ||
self._test_arg_failure( | ||
'create --image x --image-pull-policy wrong', | ||
self._invalid_choice_error) | ||
self.assertFalse(mock_create.called) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters