<s> import shutil <EOL> import tempfile <EOL> import unittest2 as unittest <EOL> from cactus . plugin . manager import PluginManager <EOL> from cactus . utils . parallel import PARALLEL_DISABLED <EOL> from cactus . config . fallback import ConfigFallback <EOL> from cactus . deployment . engine import BaseDeploymentEngine <EOL> from cactus . deployment . file import BaseFile <EOL> class DummyUI ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , bucket_name = "<STR_LIT>" , create_bucket = True ) : <EOL> self . bucket_name = bucket_name <EOL> self . create_bucket = create_bucket <EOL> self . asked_name = <NUM_LIT:0> <EOL> self . asked_create = <NUM_LIT:0> <EOL> def prompt_normalized ( self , q ) : <EOL> self . asked_name += <NUM_LIT:1> <EOL> return self . bucket_name <EOL> def prompt_yes_no ( self , q ) : <EOL> self . asked_create += <NUM_LIT:1> <EOL> return self . create_bucket <EOL> class DummyConfig ( ConfigFallback ) : <EOL> """<STR_LIT>""" <EOL> def write ( self ) : <EOL> super ( DummyConfig , self ) . write ( ) <EOL> self . saved = True <EOL> class DummyPluginManager ( PluginManager ) : <EOL> """<STR_LIT>""" <EOL> def call ( self , method , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class DummySite ( object ) : <EOL> """<STR_LIT>""" <EOL> _parallel = PARALLEL_DISABLED <EOL> def __init__ ( self , path , ui ) : <EOL> self . build_path = path <EOL> self . config = ConfigFallback ( ) <EOL> self . ui = ui <EOL> self . plugin_manager = DummyPluginManager ( self , [ ] ) <EOL> self . compress_extensions = [ ] <EOL> class DummyCredentialsManager ( object ) : <EOL> """<STR_LIT>""" <EOL> _username = "<STR_LIT>" <EOL> _password = "<STR_LIT>" <EOL> def __init__ ( self , engine ) : <EOL> self . engine = engine <EOL> self . saved = False <EOL> def get_credentials ( self ) : <EOL> return self . _username , self . _password <EOL> def save_credentials ( self ) : <EOL> self . saved = True <EOL> class DummyFile ( BaseFile ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , engine , path ) : <EOL> super ( DummyFile , self ) . __init__ ( engine , path ) <EOL> self . engine . created_files . append ( self ) <EOL> self . remote_changed_calls = <NUM_LIT:0> <EOL> self . do_upload_calls = <NUM_LIT:0> <EOL> def remote_changed ( self ) : <EOL> self . remote_changed_calls += <NUM_LIT:1> <EOL> return True <EOL> def do_upload ( self ) : <EOL> self . do_upload_calls += <NUM_LIT:1> <EOL> pass <EOL> class DummyDeploymentEngine ( BaseDeploymentEngine ) : <EOL> """<STR_LIT>""" <EOL> FileClass = DummyFile <EOL> CredentialsManagerClass = DummyCredentialsManager <EOL> config_bucket_name = "<STR_LIT>" <EOL> config_bucket_website = "<STR_LIT>" <EOL> def __init__ ( self , site ) : <EOL> super ( DummyDeploymentEngine , self ) . __init__ ( site ) <EOL> self . get_bucket_calls = <NUM_LIT:0> <EOL> self . create_bucket_calls = <NUM_LIT:0> <EOL> self . get_website_calls = <NUM_LIT:0> <EOL> self . created_files = [ ] <EOL> def _create_connection ( self ) : <EOL> pass <EOL> def get_bucket ( self ) : <EOL> self . get_bucket_calls += <NUM_LIT:1> <EOL> if self . create_bucket_calls : <EOL> return "<STR_LIT>" <EOL> return None <EOL> def create_bucket ( self ) : <EOL> self . create_bucket_calls += <NUM_LIT:1> <EOL> return "<STR_LIT>" <EOL> def get_website_endpoint ( self ) : <EOL> self . get_website_calls += <NUM_LIT:1> <EOL> return "<STR_LIT>" <EOL> class BaseDeploymentTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . test_dir = tempfile . mkdtemp ( ) <EOL> def tearDown ( self ) : <EOL> shutil . rmtree ( self . test_dir ) </s>
