<s> import tempfile <EOL> import os <EOL> import shutil <EOL> from base_test import BaseServerTestCase <EOL> from wagon . wagon import Wagon <EOL> class BaseListTest ( BaseServerTestCase ) : <EOL> def _put_deployment_modification ( self , deployment_id , <EOL> modified_nodes = None , <EOL> node_instances = None , <EOL> nodes = None ) : <EOL> resource_path = '<STR_LIT>' <EOL> data = { '<STR_LIT>' : deployment_id , <EOL> '<STR_LIT>' : modified_nodes or { } , <EOL> '<STR_LIT>' : node_instances or { } , <EOL> '<STR_LIT>' : nodes or { } } <EOL> return self . post ( resource_path , data ) . json <EOL> def _mark_deployment_modification_finished ( self , modification_id = None ) : <EOL> resource_path = '<STR_LIT>' . format ( <EOL> modification_id ) <EOL> data = { '<STR_LIT>' : modification_id } <EOL> return self . post ( resource_path , data ) . json <EOL> def _put_n_deployment_modifications ( self , id_prefix , <EOL> number_of_modifications , <EOL> skip_creation = None ) : <EOL> self . _put_n_deployments ( id_prefix , <EOL> number_of_modifications , <EOL> skip_creation = skip_creation , <EOL> add_modification = True ) <EOL> def _put_n_plugins ( self , number_of_plugins ) : <EOL> for i in range ( <NUM_LIT:0> , number_of_plugins ) : <EOL> tmpdir = tempfile . mkdtemp ( prefix = '<STR_LIT>' ) <EOL> with open ( os . path . join ( tmpdir , '<STR_LIT>' ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( '<STR_LIT>' ) <EOL> f . write ( '<STR_LIT>' . format ( i ) ) <EOL> wagon = Wagon ( tmpdir ) <EOL> plugin_path = wagon . create ( archive_destination_dir = tmpdir ) <EOL> self . post_file ( '<STR_LIT>' , plugin_path ) <EOL> shutil . rmtree ( tmpdir ) <EOL> def _put_n_deployments ( self , id_prefix , <EOL> number_of_deployments , <EOL> skip_creation = None , <EOL> add_modification = None ) : <EOL> for i in range ( <NUM_LIT:0> , number_of_deployments ) : <EOL> deployment_id = "<STR_LIT>" . format ( id_prefix , str ( i ) , <EOL> '<STR_LIT>' ) <EOL> blueprint_id = "<STR_LIT>" . format ( id_prefix , str ( i ) , '<STR_LIT>' ) <EOL> if not skip_creation : <EOL> self . put_deployment ( deployment_id = deployment_id , <EOL> blueprint_id = blueprint_id ) <EOL> if add_modification : <EOL> response = self . _put_deployment_modification ( <EOL> deployment_id = deployment_id ) <EOL> self . _mark_deployment_modification_finished ( <EOL> modification_id = response [ '<STR_LIT:id>' ] ) <EOL> def _put_n_snapshots ( self , number_of_snapshots ) : <EOL> for i in range ( number_of_snapshots ) : <EOL> self . client . snapshots . create ( snapshot_id = '<STR_LIT>' . format ( i ) , <EOL> include_metrics = False , <EOL> include_credentials = False ) </s>
