def setup_platform_workspace(self): fileoperations.create_config_file( 'my-platform', 'us-west-2', self.platform.name, workspace_type='Platform' )
def setUp(self): if not os.path.exists('testDir{}'.format(os.path.sep)): os.makedirs('testDir{}'.format(os.path.sep)) os.chdir('testDir') fileoperations.create_config_file('testapp', 'us-east-1', 'PHP') with open('myFile', 'w') as f: f.write('Hello') subprocess.call(['git', 'init']) subprocess.call( ['git', 'config', '--local', 'user.email', '*****@*****.**']) subprocess.call(['git', 'config', '--local', 'user.name', 'abc def']) subprocess.call(['git', 'add', 'myFile']) subprocess.call(['git', 'commit', '-m', 'Initial']) with open('myFile2', 'w') as f: f.write('Hello There') subprocess.call(['git', 'add', 'myFile2']) subprocess.call(['git', 'commit', '-m', 'Hello']) subprocess.call(['git', 'tag', '-a', 'v1', '-m', 'my version']) self.patcher_io = mock.patch('ebcli.objects.sourcecontrol.io') self.mock_input = self.patcher_io.start()
def setup_application_workspace(self): fileoperations.create_config_file( 'my-application', 'us-west-2', self.solution_stack.name, workspace_type='Application' )
def setUp(self): super(TestAbort, self).setUp() fileoperations.create_config_file('myEBCLItest', 'us-west-2', 'my-stack-stack') commonops.set_environment_for_current_branch('my-env') mockservice.enqueue('elasticbeanstalk', 'AbortEnvironmentUpdate', standard_abort())
def setUp(self): self.root_dir = os.getcwd() if not os.path.exists('testDir'): os.mkdir('testDir') os.chdir('testDir') fileoperations.create_config_file('test-app', 'us-west-2', 'php')
def setUp(self): self.root_dir = os.getcwd() if not os.path.exists('testDir'): os.mkdir('testDir') os.chdir('testDir') fileoperations.create_config_file('my-application', 'us-west-2', self.platform.name)
def create_config_file_in(self, path): original_dir = os.getcwd() os.chdir(path) fileoperations.create_config_file( 'my-application', 'us-west-2', self.platform.name ) os.chdir(original_dir)
def setUp(self): self.root_dir = os.getcwd() if not os.path.exists('testDir'): os.mkdir('testDir') os.chdir('testDir') open('.gitignore', 'w').close() fileoperations.create_config_file( 'my-application', 'us-west-2', '64bit Amazon Linux 2014.03 v1.0.6 running PHP 5.5')
def test_get_config_setting_no_global(self): if os.path.exists(fileoperations.global_config_file): os.remove(fileoperations.global_config_file) self.assertFalse(os.path.exists(fileoperations.global_config_file)) fileoperations.create_config_file('ebcli-test', 'us-east-1', 'my-solution-stack') result = fileoperations.get_config_setting('global', 'application_name') self.assertEqual(result, 'ebcli-test')
def test_write_config_setting_no_section(self): fileoperations.create_config_file('ebcli-test', 'us-east-1', 'my-solution-stack') dict = fileoperations._get_yaml_dict(fileoperations.local_config_file) self.assertFalse('mytestsection' in dict) fileoperations.write_config_setting('mytestsection', 'testkey', 'value') dict = fileoperations._get_yaml_dict(fileoperations.local_config_file) self.assertTrue('mytestsection' in dict)
def setUp(self): self.root_dir = os.getcwd() if not os.path.exists('testDir'): os.mkdir('testDir') os.chdir('testDir') fileoperations.create_config_file( app_name='my-app', region='us-west-2', solution_stack='64bit Amazon Linux 2014.03 v1.0.6 running PHP 5.5', )
def test_get_config_setting_merge(self): config = {'global': {'application_name': 'myApp'}} with open(fileoperations.global_config_file, 'w') as f: f.write(yaml.dump(config, default_flow_style=False)) self.assertTrue(os.path.exists(fileoperations.global_config_file)) fileoperations.create_config_file('ebcli-test', 'us-east-1', 'my-solution-stack') result = fileoperations.get_config_setting('global', 'application_name') self.assertEqual(result, 'ebcli-test')
def test_create_config_file_no_file(self): if os.path.exists(fileoperations.local_config_file): os.remove(fileoperations.local_config_file) self.assertFalse(os.path.exists(fileoperations.local_config_file)) app_name = 'ebcli-test' region = 'us-east-1' solution = 'my-solution-stack' fileoperations.create_config_file(app_name, region, solution) self.assertTrue(os.path.exists(fileoperations.local_config_file)) rslt = fileoperations.get_config_setting('global', 'application_name') self.assertEqual(app_name, rslt)
def test_write_config_setting_override(self): fileoperations.create_config_file('ebcli-test', 'us-east-1', 'my-solution-stack') dict = fileoperations._get_yaml_dict(fileoperations.local_config_file) self.assertTrue('global' in dict) self.assertTrue('application_name' in dict['global']) self.assertTrue('application_name' in dict['global']) self.assertEqual(dict['global']['application_name'], 'ebcli-test') fileoperations.write_config_setting('global', 'application_name', 'new_name') dict = fileoperations._get_yaml_dict(fileoperations.local_config_file) self.assertEqual(dict['global']['application_name'], 'new_name')
def test_init__attempt_to_init_inside_application_workspace(self): fileoperations.create_config_file( 'my-application', 'us-west-2', 'php', ) app = EB(argv=['platform', 'init']) app.setup() with self.assertRaises(EnvironmentError) as context_manager: app.run() self.assertEqual( 'This directory is already initialized with an application workspace.', str(context_manager.exception) )
def test_create_config_file_file_exists(self): fileoperations.write_config_setting('global', 'randomKey', 'val') fileoperations.write_config_setting('test', 'application_name', 'app1') app_name = 'ebcli-test' region = 'us-east-1' solution = 'my-solution-stack' fileoperations.create_config_file(app_name, region, solution) key = fileoperations.get_config_setting('global', 'randomKey') app = fileoperations.get_config_setting('global', 'application_name') test = fileoperations.get_config_setting('test', 'application_name') self.assertEqual(key, 'val') self.assertEqual(app, app_name) self.assertEqual(test, 'app1')
def test_create_config_file_no_dir(self): if os.path.exists(fileoperations.beanstalk_directory): shutil.rmtree(fileoperations.beanstalk_directory, ignore_errors=True) self.assertFalse(os.path.exists(fileoperations.beanstalk_directory)) app_name = 'ebcli-test' region = 'us-east-1' solution = 'my-solution-stack' fileoperations.create_config_file(app_name, region, solution) self.assertTrue(os.path.exists(fileoperations.beanstalk_directory)) self.assertTrue(os.path.exists(fileoperations.local_config_file)) rslt = fileoperations.get_config_setting('global', 'application_name') self.assertEqual(app_name, rslt)
def setUp(self): if not os.path.exists('testDir'): os.makedirs('testDir') os.chdir('testDir') if not os.path.exists(fileoperations.beanstalk_directory): os.makedirs(fileoperations.beanstalk_directory) if not os.path.exists('home'): os.makedirs('home') fileoperations.aws_config_folder = 'home' + os.path.sep fileoperations.aws_config_location \ = fileoperations.aws_config_folder + 'config' fileoperations.create_config_file('ebcli-test', 'us-east-1', 'my-solution-stack')
def test_health__mono( self, get_instance_health_mock, get_environment_health_mock, describe_configuration_settings_mock ): fileoperations.create_config_file( 'my-application', 'us-west-2', 'php-7.2' ) commonops.set_environment_for_current_branch('environment-1') describe_configuration_settings_mock.return_value = mock_responses.DESCRIBE_CONFIGURATION_SETTINGS_RESPONSE__2['ConfigurationSettings'][0] get_environment_health_mock.return_value = mock_responses.DESCRIBE_ENVIRONMENT_HEALTH_RESPONSE get_instance_health_mock.return_value = mock_responses.DESCRIBE_INSTANCES_HEALTH_RESPONSE app = EB(argv=['health', '--mono']) app.setup() app.run()
def setup_directory(app_name, region, solution, workspace_type, platform_name, platform_version, instance_profile, dir_path=None, repository=None, branch=None): io.log_info('Setting up .elasticbeanstalk directory') fileoperations.create_config_file(app_name, region, solution, workspace_type, platform_name, platform_version, instance_profile, dir_path=dir_path, repository=repository, branch=branch)
def setup_application_workspace(self): fileoperations.create_config_file('my-application', 'us-west-2', 'php-7.1', workspace_type='Application')
def create_config_file(self): app_name = 'ebcli-test' region = 'us-east-1' solution = 'my-solution-stack' fileoperations.create_config_file(app_name, region, solution)