def test_02_deploy(self): commandOut = self.redirectStdOut() client_settings = mmutil.parse_json_from_file(os.path.join(test_helper.base_test_directory, "user_client_settings.json")) org_connections = test_util.parse_json_from_file(os.path.join(client_settings["mm_workspace"],"unit test deploy project","config",".org_connections")) stdin = { "project_name" : "unit test deploy project", "destinations" : [ { "id" : org_connections[0]["id"], "username" : org_connections[0]["username"], "org_type" : org_connections[0]["environment"] } ], "check_only" : True, "run_tests" : False, "rollback_on_error" : True, "package" : { "ApexClass" : ["CompileAndTest"] }, "debug_categories" : "" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'deploy', '--html'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = test_util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True)
def test_02_should_deploy_to_server(self): client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) org_connections = test_util.parse_json_from_file( os.path.join(client_settings["mm_workspace"], "unit test deploy project", "config", ".org_connections")) stdin = { "project_name": "unit test deploy project", "destinations": [{ "id": org_connections[0]["id"], "username": org_connections[0]["username"], "org_type": org_connections[0]["environment"] }], "check_only": True, "run_tests": False, "rollback_on_error": True, "package": { "ApexClass": ["CompileAndTest"] }, "debug_categories": "" } mm_response = self.runCommand(['mm.py', '-o', 'deploy', '--html'], stdin) self.assertTrue(mm_response['success'] == True)
def test_03_should_delete_org_connection(self): client_settings = mmutil.parse_json_from_file(os.path.join(test_helper.base_test_directory, "user_client_settings.json")) org_connections = test_util.parse_json_from_file(os.path.join(client_settings["mm_workspace"],"unit test deploy project","config",".org_connections")) stdin = { "id" : org_connections[0]["id"], "project_name" : "unit test deploy project" } mm_response = self.runCommand('delete_connection', stdin) self.assertTrue(mm_response['success'] == True)
def test_03_should_delete_org_connection(self): client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) org_connections = test_util.parse_json_from_file( os.path.join(client_settings["mm_workspace"], "unit test deploy project", "config", ".org_connections")) stdin = { "id": org_connections[0]["id"], "project_name": "unit test deploy project" } mm_response = self.runCommand('delete_connection', stdin) self.assertTrue(mm_response['success'] == True)
def test_03_delete_org_connection(self): commandOut = self.redirectStdOut() client_settings = mmutil.parse_json_from_file(os.path.join(test_helper.base_test_directory, "user_client_settings.json")) org_connections = test_util.parse_json_from_file(os.path.join(client_settings["mm_workspace"],"unit test deploy project","config",".org_connections")) stdin = { "id" : org_connections[0]["id"], "project_name" : "unit test deploy project" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'delete_connection'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = test_util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True)
def test_02_should_deploy_to_server(self): client_settings = mmutil.parse_json_from_file(os.path.join(test_helper.base_test_directory, "user_client_settings.json")) org_connections = test_util.parse_json_from_file(os.path.join(client_settings["mm_workspace"],"unit test deploy project","config",".org_connections")) stdin = { "project_name" : "unit test deploy project", "destinations" : [ { "id" : org_connections[0]["id"], "username" : org_connections[0]["username"], "org_type" : org_connections[0]["environment"] } ], "check_only" : True, "run_tests" : False, "rollback_on_error" : True, "package" : { "ApexClass" : ["CompileAndTest"] }, "debug_categories" : "" } mm_response = self.runCommand(['mm.py', '-o', 'deploy', '--html'], stdin) self.assertTrue(mm_response['success'] == True)
def test_02_new_apex_checkpoint(self): test_helper.create_project("unit test tooling project") commandOut = self.redirectStdOut() ###CREATE APEX CLASS # stdin = { # "github_template": { # "author": "MavensMate", # "description": "The default template for an Apex Class", # "name": "Default", # "file_name": "ApexClass.cls" # }, # "apex_trigger_object_api_name": None, # "apex_class_type": None, # "api_name": "unittesttoolingapexclass", # "project_name": "unit test tooling project", # "metadata_type": "ApexClass" # } stdin = { 'project_name' : 'unit test tooling project', 'metadata_type': 'ApexClass', 'params': {'api_name': 'unittesttoolingapexclass'}, 'github_template': { 'author': 'MavensMate', 'name': 'Default', 'description': 'The default template for an Apex Class', 'file_name': 'ApexClass.cls', 'params': [ { 'default': 'MyApexClass', 'name': 'api_name', 'description': 'Apex Class API Name' } ] } } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_metadata'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True) self.assertTrue('id' in mm_json_response and len(mm_json_response['id']) is 18) ###CREATE CHECKPOINT stdin = { "project_name" : "unit test tooling project", "IsDumpingHeap" : True, "Iteration" : 1, "Object_Type" : "ApexClass", "Line" : 1, "ActionScriptType" : "None", "API_Name" : "unittesttoolingapexclass" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_apex_overlay'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True) self.assertTrue('id' in mm_json_response and len(mm_json_response['id']) is 18) ###DELETE CLASS client_settings = util.parse_json_from_file(os.path.join(test_helper.base_test_directory, "user_client_settings.json")) stdin = { "files": [os.path.join(client_settings["mm_workspace"],"unit test tooling project","src","classes","unittesttoolingapexclass.cls")], "project_name": "unit test tooling project" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'delete'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True)
def test_02_new_apex_checkpoint(self): test_helper.create_project("unit test tooling project") commandOut = self.redirectStdOut() ###CREATE APEX CLASS stdin = { "github_template": { "author": "MavensMate", "description": "The default template for an Apex Class", "name": "Default", "file_name": "ApexClass.cls" }, "apex_trigger_object_api_name": None, "apex_class_type": None, "api_name": "unittesttoolingapexclass", "project_name": "unit test tooling project", "metadata_type": "ApexClass" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_metadata'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True) self.assertTrue('id' in mm_json_response and len(mm_json_response['id']) is 18) ###CREATE CHECKPOINT stdin = { "project_name": "unit test tooling project", "IsDumpingHeap": True, "Iteration": 1, "Object_Type": "ApexClass", "Line": 1, "ActionScriptType": "None", "API_Name": "unittesttoolingapexclass" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_apex_overlay'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True) self.assertTrue('id' in mm_json_response and len(mm_json_response['id']) is 18) ###DELETE CLASS client_settings = util.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) stdin = { "files": [ os.path.join(client_settings["mm_workspace"], "unit test tooling project", "src", "classes", "unittesttoolingapexclass.cls") ], "project_name": "unit test tooling project" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'delete'] MavensMateRequestHandler().execute() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True)
def test_03_should_create_new_apex_checkpoint(self): ###CREATE APEX CLASS stdin = { 'project_name': 'unit test tooling project', 'metadata_type': 'ApexClass', 'params': { 'api_name': 'unittesttoolingapexclass' }, 'github_template': { 'author': 'MavensMate', 'name': 'Default', 'description': 'The default template for an Apex Class', 'file_name': 'ApexClass.cls', 'params': [{ 'default': 'MyApexClass', 'name': 'api_name', 'description': 'Apex Class API Name' }] } } mm_response = self.runCommand('new_metadata', stdin) if 'success' in mm_response and mm_response['success']: self.assertTrue(mm_response['success'] == True) self.assertTrue('id' in mm_response and len(mm_response['id']) is 18) elif 'success' in mm_response and not mm_response['success']: if 'body' in mm_response and mm_response[ 'body'] == 'This API name is already in use in your org.': # probably by accident, this is ok bc we clean it up at the end pass ###CREATE CHECKPOINT stdin = { "project_name": "unit test tooling project", "IsDumpingHeap": True, "Iteration": 1, "Object_Type": "ApexClass", "Line": 1, "ActionScriptType": "None", "API_Name": "unittesttoolingapexclass" } mm_response = self.runCommand('new_apex_overlay', stdin) self.assertEqual(mm_response['success'], True) ###DELETE CLASS client_settings = util.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) stdin = { "files": [ os.path.join(client_settings["mm_workspace"], "unit test tooling project", "src", "classes", "unittesttoolingapexclass.cls") ], "project_name": "unit test tooling project" } mm_response = self.runCommand('delete', stdin) self.assertEqual(mm_response['success'], True)