<s> import dateutil . parser <EOL> import sys <EOL> import mock <EOL> from mock import patch <EOL> from test_helper import * <EOL> import datetime <EOL> import azurectl <EOL> from azurectl . azurectl_exceptions import * <EOL> from azurectl . commands . storage_container import StorageContainerTask <EOL> class TestStorageContainerTask : <EOL> def setup ( self ) : <EOL> sys . argv = [ <EOL> sys . argv [ <NUM_LIT:0> ] , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' <EOL> ] <EOL> azurectl . commands . storage_container . AzureAccount . storage_names = mock . Mock ( <EOL> return_value = mock . Mock ( ) <EOL> ) <EOL> self . storage = mock . Mock ( ) <EOL> self . storage . upload = mock . Mock ( ) <EOL> azurectl . commands . storage_container . Container = mock . Mock ( <EOL> return_value = mock . Mock ( ) <EOL> ) <EOL> azurectl . commands . storage_container . Help = mock . Mock ( <EOL> return_value = mock . Mock ( ) <EOL> ) <EOL> self . task = StorageContainerTask ( ) <EOL> self . __init_command_args ( ) <EOL> def __init_command_args ( self ) : <EOL> self . task . command_args = { } <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> self . task . command_args [ '<STR_LIT:list>' ] = False <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . task . command_args [ '<STR_LIT>' ] = False <EOL> def test_process_storage_container_delete ( self ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> self . task . container . delete . assert_called_once_with ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> def test_process_storage_container_create ( self ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> self . task . container . create . assert_called_once_with ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_process_storage_container_show ( self , mock_out ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> self . task . container . content . assert_called_once_with ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> @ raises ( AzureInvalidCommand ) <EOL> def test_start_date_validation ( self ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT:foo>' <EOL> self . task . process ( ) <EOL> @ raises ( AzureInvalidCommand ) <EOL> def test_end_date_validation ( self ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT:foo>' <EOL> self . task . process ( ) <EOL> @ raises ( AzureInvalidCommand ) <EOL> def test_permissions_validation ( self ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT:a>' <EOL> self . task . process ( ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_process_storage_container_sas ( self , mock_out ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> start = dateutil . parser . parse ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> expiry = dateutil . parser . parse ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> self . task . container . sas . assert_called_once_with ( <EOL> self . task . command_args [ '<STR_LIT>' ] , start , expiry , '<STR_LIT>' <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_process_storage_container_sas_now ( self , mock_out ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> expiry = dateutil . parser . parse ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> self . task . container . sas . assert_called_once_with ( <EOL> self . task . command_args [ '<STR_LIT>' ] , mock . ANY , expiry , '<STR_LIT>' <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_process_storage_container_sas_expire ( self , mock_out ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> start = dateutil . parser . parse ( <EOL> self . task . command_args [ '<STR_LIT>' ] <EOL> ) <EOL> expiry = start + datetime . timedelta ( days = <NUM_LIT:30> ) <EOL> self . task . container . sas . assert_called_once_with ( <EOL> self . task . command_args [ '<STR_LIT>' ] , start , expiry , '<STR_LIT>' <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_process_storage_container_list ( self , mock_out ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT:list>' ] = True <EOL> self . task . process ( ) <EOL> self . task . container . list . assert_called_once_with ( ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_process_storage_container_from_cfg_list ( self , mock_out ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT:list>' ] = True <EOL> self . task . process ( ) <EOL> self . task . container . list . assert_called_once_with ( ) <EOL> def test_process_storage_container_help ( self ) : <EOL> self . __init_command_args ( ) <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . command_args [ '<STR_LIT>' ] = True <EOL> self . task . process ( ) <EOL> self . task . manual . show . assert_called_once_with ( <EOL> '<STR_LIT>' <EOL> ) </s>
