def test_01_refresh_apex_class(self): apex_class_name = "unittestapexclass" files = [ os.path.join(test_helper.base_test_directory, "test_workspace", project_name, "src", "classes", apex_class_name + ".cls") ] test_helper.create_project(project_name) test_helper.create_apex_metadata(project_name, "ApexClass", apex_class_name) commandOut = self.redirectStdOut() stdin = { "project_name": project_name, "directories": [], "files": files } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'refresh'] 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.assertEqual("Refresh Completed Successfully", mm_json_response['body']) test_helper.delete_apex_metadata(project_name, files=files)
def test_01_refresh_apex_class(self): apex_class_name = "unittestapexclass" files = [os.path.join(base_test_directory,"test_workspace",project_name,"src","classes",apex_class_name+".cls")] test_helper.create_project(project_name) test_helper.create_apex_metadata(project_name, "ApexClass", apex_class_name) commandOut = self.redirectStdOut() stdin = { "project_name" : project_name, "directories" : [], "files" : files } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'refresh'] mm.main() 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.assertEqual("Refresh Completed Successfully",mm_json_response['body']) test_helper.delete_apex_metadata(project_name, files=files)
def test_02_compile_apex_class(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json") ) stdin = { "project_name": "unit test metadata project", "files": [ os.path.join( client_settings["mm_workspace"], "unit test metadata project", "src", "classes", "unittestapexclass.cls", ) ], } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ["mm.py", "-o", "compile"] 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["State"] == "Completed") self.assertTrue(mm_json_response["ErrorMsg"] == None)
def test_01_new_apex_class(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() 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": "unittestapexclass", "project_name": "unit test metadata project", "metadata_type": "ApexClass" } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_metadata'] mm.main() 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)
def test_01_compile_with_tooling_api(self): client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json") ) test_helper.create_project("unit test metadata project") test_helper.create_apex_metadata("unit test metadata project", "ApexClass", "unittestapexclass") commandOut = self.redirectStdOut() test_helper.compile( "unit test metadata project", [ os.path.join( client_settings["mm_workspace"], "unit test metadata project", "src", "classes", "unittestapexclass.cls", ) ], ) 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["State"] == "Completed") self.assertTrue(mm_json_response["CompilerErrors"] == "[]")
def test_01_should_delete_trace_flags(self): test_helper.create_project(self, "unit test tooling project") stdin = { "project_name" : "unit test tooling project" } mm_response = self.runCommand('delete_trace_flags', stdin) self.assertTrue(mm_response['success'] == True)
def test_01_should_run_tests_async(self): project_name = 'unit test project' test_helper.create_project(self, project_name, package={ "ApexClass" : ["CompileAndTest"] }) apex_class_name = "unittestapexclass" files = [os.path.join(test_helper.base_test_directory,"test_workspace",project_name,"src","classes",apex_class_name+".cls")] template = { 'author': 'MavensMate', 'name': 'Unit Test', 'description': 'Unit test class', 'file_name': 'UnitTestApexClass.cls', 'params': [ { 'default': 'MyApexClass', 'name': 'api_name', 'description': 'Apex Class API Name' } ] } test_helper.create_apex_metadata(self, project_name, "ApexClass", apex_class_name, template) stdin = { "project_name" : project_name, "classes" : ["unittestapexclass"] } mm_response = self.runCommand('test_async', stdin) self.assertTrue(len(mm_response) == 1) self.assertTrue(mm_response[0]['Status'] == 'Completed') self.assertTrue('ExtendedStatus' in mm_response[0]) test_helper.delete_apex_metadata(self, project_name, files=files)
def test_01_should_create_new_apex_class(self): test_helper.create_project(self, "unit test metadata project") stdin = { 'project_name': 'unit test metadata project', 'metadata_type': 'ApexClass', 'params': { 'api_name': 'unittestapexclass' }, '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) self.assertTrue(mm_response['success'] == True) self.assertTrue('id' in mm_response and len(mm_response['id']) is 18)
def test_01_should_get_coverage(self): test_helper.create_project(self, "unit test project", package={ "ApexClass" : "*" }) stdin = { "project_name" : "unit test project" } mm_response = self.runCommand('code_coverage_report', stdin) self.assertTrue(mm_json_response['totalSize'] > 0) self.assertTrue(mm_json_response['done'] == True) self.assertTrue(mm_json_response['entityTypeName'] == "ApexCodeCoverageAggregate")
def test_01_should_get_coverage(self): test_helper.create_project(self, "unit test project", package={"ApexClass": "*"}) stdin = {"project_name": "unit test project"} mm_response = self.runCommand('code_coverage_report', stdin) self.assertTrue(mm_json_response['totalSize'] > 0) self.assertTrue(mm_json_response['done'] == True) self.assertTrue( mm_json_response['entityTypeName'] == "ApexCodeCoverageAggregate")
def test_01_should_create_new_org_connection(self): test_helper.create_project(self, "unit test deploy project") stdin = { "username": "******", "password": "******", "org_type": "developer", "project_name": "unit test deploy project" } mm_response = self.runCommand('new_connection', stdin) self.assertTrue(mm_response['success'] == True)
def test_01_should_create_new_org_connection(self): test_helper.create_project(self, "unit test deploy project") stdin = { "username" : "*****@*****.**", "password" : "force", "org_type" : "developer", "project_name" : "unit test deploy project" } mm_response = self.runCommand('new_connection', stdin) self.assertTrue(mm_response['success'] == True)
def test_02_should_compile_apex_class(self): test_helper.create_project(self, "unit test metadata project") client_settings = mmutil.parse_json_from_file(os.path.join(test_helper.base_test_directory, "user_client_settings.json")) stdin = { "project_name": "unit test metadata project", "files": [os.path.join(test_helper.base_test_directory,"test_workspace","unit test metadata project","src","classes","unittestapexclass.cls")] } mm_response = self.runCommand('compile', stdin) self.assertTrue(mm_response['State'] == "Completed") self.assertTrue(mm_response['ErrorMsg'] == None)
def test_01_should_compile_with_tooling_api(self): test_helper.create_project(self, "unit test metadata project") test_helper.create_apex_metadata(self, "unit test metadata project", "ApexClass", "unittestapexclass") mm_response = test_helper.compile(self, "unit test metadata project", [os.path.join(test_helper.base_test_directory,"test_workspace","unit test metadata project","src","classes","unittestapexclass.cls")]) self.assertTrue(mm_response['State'] == 'Completed') if self.getTestApiVersion() <= 30: self.assertTrue(mm_response['CompilerErrors'] == '[]') else: self.assertTrue('DeployDetails' in mm_response) self.assertTrue(mm_response['DeployDetails']['componentSuccesses'] == [])
def test_01_new_debug_log(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() stdin = { "project_name" : "unit test metadata project", } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_metadata'] mm.main() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response
def test_01_should_create_new_stack_trace(self): test_helper.create_project(self, "unit test tooling project") stdin = { "project_name": "unit test tooling project", "type": "user", "debug_categories": { "ApexCode": "DEBUG", "Visualforce": "DEBUG" } } mm_response = self.runCommand('new_log', stdin) self.assertEqual(mm_response['success'], True) self.assertTrue('id' in mm_response and len(mm_response['id']) is 18)
def test_01_delete_trace_flags(self): test_helper.create_project("unit test tooling project") commandOut = self.redirectStdOut() stdin = { "project_name" : "unit test tooling project" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'delete_trace_flags'] 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_01_new_apex_class(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() # 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": "unittestapexclass", # "project_name": "unit test metadata project", # "metadata_type": "ApexClass" # } stdin = { 'project_name': 'unit test metadata project', 'metadata_type': 'ApexClass', 'params': { 'api_name': 'unittestapexclass' }, '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 = test_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)
def test_01_get_coverage(self): test_helper.create_project("unit test project", package={ "ApexClass" : "*" }) commandOut = self.redirectStdOut() stdin = { "project_name" : "unit test project" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'code_coverage_report'] 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['totalSize'] > 0) self.assertTrue(mm_json_response['done'] == True) self.assertTrue(mm_json_response['entityTypeName'] == "ApexCodeCoverageAggregate")
def test_01_should_refresh_apex_class(self): apex_class_name = "unittestapexclass" files = [os.path.join(test_helper.base_test_directory,"test_workspace",project_name,"src","classes",apex_class_name+".cls")] test_helper.create_project(self, project_name) test_helper.create_apex_metadata(self, project_name, "ApexClass", apex_class_name) stdin = { "project_name" : project_name, "directories" : [], "files" : files } mm_response = self.runCommand('refresh', stdin) self.assertTrue(mm_response['success'] == True) self.assertEqual("Refresh Completed Successfully",mm_response['body']) test_helper.delete_apex_metadata(self, project_name, files=files)
def test_should_except_for_bad_package(self): package = {} mm_response = test_helper.create_project(self, "unit test project", package=package) self.assertTrue(mm_response['success'] == False) self.assertTrue(mm_response['body'] == 'Invalid package')
def test_01_run_tests_async(self): test_helper.create_project("unit test project", package={ "ApexClass" : ["CompileAndTest"] }) commandOut = self.redirectStdOut() stdin = { "project_name" : "unit test project", "classes" : ["CompileAndTest"] } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'test_async'] mm.main() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout #print mm_response mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(len(mm_json_response) == 1) self.assertTrue(mm_json_response[0]['Status'] == 'Completed')
def test_should_create_new_project_with_all_objects(self): package = {"CustomObject": "*"} project_name = 'unit test project' mm_response = test_helper.create_project(self, project_name, package=package) self.assertTrue(mm_response['success'] == True) self.assertTrue(mm_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue( os.path.exists( os.path.join(base_test_directory, 'test_workspace', project_name))) self.assertTrue( os.path.exists( os.path.join(base_test_directory, 'test_workspace', project_name, 'src'))) self.assertTrue( os.path.exists( os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects'))) self.assertTrue( os.path.isfile( os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects', 'Account.object'))) self.assertTrue( os.path.isfile( os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects', 'Opportunity.object'))) self.assertTrue( os.path.isfile( os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects', 'Lead.object')))
def test_01_get_coverage(self): test_helper.create_project("unit test project", package={"ApexClass": "*"}) commandOut = self.redirectStdOut() stdin = {"project_name": "unit test project"} request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'code_coverage_report'] 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['totalSize'] > 0) self.assertTrue(mm_json_response['done'] == True) self.assertTrue( mm_json_response['entityTypeName'] == "ApexCodeCoverageAggregate")
def test_02_compile_apex_class(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() client_settings = mm_util.parse_json_from_file(os.path.join(base_test_directory, "user_client_settings.json")) stdin = { "project_name": "unit test metadata project", "files": [os.path.join(client_settings["mm_workspace"],"unit test metadata project","src","classes","unittestapexclass.cls")] } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'compile'] mm.main() 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['State'] == "Completed") self.assertTrue(mm_json_response['ErrorMsg'] == None)
def test_01_run_tests_async(self): test_helper.create_project("unit test project", package={"ApexClass": ["CompileAndTest"]}) commandOut = self.redirectStdOut() stdin = { "project_name": "unit test project", "classes": ["CompileAndTest"] } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'test_async'] 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(len(mm_json_response) == 1) self.assertTrue(mm_json_response[0]['Status'] == 'Completed')
def test_01_new_health_check(self): if not os.path.exists(os.path.join(base_test_directory,"test_workspace",project_name)): package = { "ApexClass" : "*", "ApexTrigger" : "*", "ApexPage" : "*" } test_helper.create_project(self, project_name, package) stdin = { "project_name" : project_name, "type" : "user", "debug_categories" : { "ApexCode" : "DEBUG", "Visualforce" : "INFO" } } mm_response = self.runCommand('project_health_check', stdin)
def test_02_should_compile_apex_class(self): test_helper.create_project(self, "unit test metadata project") client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) stdin = { "project_name": "unit test metadata project", "files": [ os.path.join(test_helper.base_test_directory, "test_workspace", "unit test metadata project", "src", "classes", "unittestapexclass.cls") ] } mm_response = self.runCommand('compile', stdin) self.assertTrue(mm_response['State'] == "Completed") self.assertTrue(mm_response['ErrorMsg'] == None)
def test_01_new_org_connection(self): test_helper.create_project("unit test deploy project") commandOut = self.redirectStdOut() stdin = { "username" : "*****@*****.**", "password" : "force", "org_type" : "developer", "project_name" : "unit test deploy project" } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_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_should_create_new_project_based_on_package_xml_file(self): package = os.path.join(base_test_directory, 'functional', 'project', 'package.xml') project_name = 'unit test project' mm_response = test_helper.create_project(self, project_name, package=package) self.assertTrue(mm_response['success'] == True) self.assertTrue(mm_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', project_name))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', project_name, 'src'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'classes')))
def test_01_compile_with_tooling_api(self): client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) test_helper.create_project("unit test metadata project") test_helper.create_apex_metadata("unit test metadata project", "ApexClass", "unittestapexclass") commandOut = self.redirectStdOut() test_helper.compile("unit test metadata project", [ os.path.join(client_settings["mm_workspace"], "unit test metadata project", "src", "classes", "unittestapexclass.cls") ]) 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['State'] == 'Completed') self.assertTrue(mm_json_response['CompilerErrors'] == '[]')
def test_01_new_debug_log(self): test_helper.create_project("unit test tooling project") commandOut = self.redirectStdOut() stdin = { "project_name" : "unit test tooling project", "type" : "user", "debug_categories" : { "ApexCode" : "DEBUG", "Visualforce" : "INFO" } } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_log'] mm.main() 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)
def test_01_(self): test_helper.create_project() commandOut = self.redirectStdOut() stdin = { "project_name": "unit test tooling project", "type": "user", "debug_categories": { "ApexCode": "DEBUG", "Visualforce": "INFO" } } util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'new_log'] mm.main() 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)
def test_01_new_health_check(self): if not os.path.exists( os.path.join(base_test_directory, "test_workspace", project_name)): package = {"ApexClass": "*", "ApexTrigger": "*", "ApexPage": "*"} test_helper.create_project(project_name, package) commandOut = self.redirectStdOut() stdin = { "project_name": project_name, "type": "user", "debug_categories": { "ApexCode": "DEBUG", "Visualforce": "INFO" } } util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'project_health_check'] mm.main() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response
def test_01_should_refresh_apex_class(self): apex_class_name = "unittestapexclass" files = [ os.path.join(test_helper.base_test_directory, "test_workspace", project_name, "src", "classes", apex_class_name + ".cls") ] test_helper.create_project(self, project_name) test_helper.create_apex_metadata(self, project_name, "ApexClass", apex_class_name) stdin = { "project_name": project_name, "directories": [], "files": files } mm_response = self.runCommand('refresh', stdin) self.assertTrue(mm_response['success'] == True) self.assertEqual("Refresh Completed Successfully", mm_response['body']) test_helper.delete_apex_metadata(self, project_name, files=files)
def test_01_new_apex_class(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() # 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": "unittestapexclass", # "project_name": "unit test metadata project", # "metadata_type": "ApexClass" # } stdin = { "project_name": "unit test metadata project", "metadata_type": "ApexClass", "params": {"api_name": "unittestapexclass"}, "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 = test_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)
def test_01_should_run_tests_async(self): project_name = 'unit test project' test_helper.create_project(self, project_name, package={"ApexClass": ["CompileAndTest"]}) apex_class_name = "unittestapexclass" files = [ os.path.join(test_helper.base_test_directory, "test_workspace", project_name, "src", "classes", apex_class_name + ".cls") ] template = { 'author': 'MavensMate', 'name': 'Unit Test', 'description': 'Unit test class', 'file_name': 'UnitTestApexClass.cls', 'params': [{ 'default': 'MyApexClass', 'name': 'api_name', 'description': 'Apex Class API Name' }] } test_helper.create_apex_metadata(self, project_name, "ApexClass", apex_class_name, template) stdin = { "project_name": project_name, "classes": ["unittestapexclass"] } mm_response = self.runCommand('test_async', stdin) self.assertTrue(len(mm_response) == 1) self.assertTrue(mm_response[0]['Status'] == 'Completed') self.assertTrue('ExtendedStatus' in mm_response[0]) test_helper.delete_apex_metadata(self, project_name, files=files)
def test_01_should_create_new_apex_class(self): test_helper.create_project(self, "unit test metadata project") stdin = { 'project_name' : 'unit test metadata project', 'metadata_type': 'ApexClass', 'params': {'api_name': 'unittestapexclass'}, '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) self.assertTrue(mm_response['success'] == True) self.assertTrue('id' in mm_response and len(mm_response['id']) is 18)
def test_01_new_health_check(self): if not os.path.exists(os.path.join(base_test_directory,"test_workspace",project_name)): package = { "ApexClass" : "*", "ApexTrigger" : "*", "ApexPage" : "*" } test_helper.create_project(project_name, package) commandOut = self.redirectStdOut() stdin = { "project_name" : project_name, "type" : "user", "debug_categories" : { "ApexCode" : "DEBUG", "Visualforce" : "INFO" } } mm_util.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'project_health_check'] mm.main() mm_response = commandOut.getvalue() sys.stdout = self.saved_stdout print mm_response
def test_should_create_new_project_with_all_objects(self): package = { "CustomObject" : "*" } project_name = 'unit test project' mm_response = test_helper.create_project(self, project_name, package=package) self.assertTrue(mm_response['success'] == True) self.assertTrue(mm_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', project_name))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', project_name, 'src'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects'))) self.assertTrue(os.path.isfile(os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects', 'Account.object'))) self.assertTrue(os.path.isfile(os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects', 'Opportunity.object'))) self.assertTrue(os.path.isfile(os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'objects', 'Lead.object')))
def test_02_compile_apex_class(self): test_helper.create_project("unit test metadata project") commandOut = self.redirectStdOut() client_settings = mmutil.parse_json_from_file( os.path.join(test_helper.base_test_directory, "user_client_settings.json")) stdin = { "project_name": "unit test metadata project", "files": [ os.path.join(client_settings["mm_workspace"], "unit test metadata project", "src", "classes", "unittestapexclass.cls") ] } request.get_request_payload = mock.Mock(return_value=stdin) sys.argv = ['mm.py', '-o', 'compile'] 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['State'] == "Completed") self.assertTrue(mm_json_response['ErrorMsg'] == None)
def test_01_should_create_new_project(self): package = { "ApexClass" : "*", "ApexPage" : "*", "Report" : [], "Document" : [] } mm_response = test_helper.create_project(self, "unit test project", package=package) self.assertTrue(mm_response['success'] == True) self.assertTrue(mm_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'src'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'src', 'classes'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'src', 'pages'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'src', 'reports'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'src', 'documents'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'src', 'documents', 'MavensMate_Documents')))
def test_01_create_new_project(self): package = { "ApexClass" : "*", "ApexPage" : "*", "Report" : [], "Document" : [] } stdin = test_helper.create_project("unit test project", package=package) mm_response = self.output.getvalue() sys.stdout = self.saved_stdout mm_json_response = util.parse_mm_response(mm_response) self.assertTrue(mm_json_response['success'] == True) self.assertTrue(mm_json_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name']))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'classes'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'pages'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'reports'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'documents'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'documents', 'MavensMate_Documents')))
def test_01_create_new_project(self): package = { "ApexClass" : "*", "ApexPage" : "*", "Report" : [], "Document" : [] } stdin = test_helper.create_project("unit test project", package=package) mm_response = self.output.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(mm_json_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name']))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'classes'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'pages'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'reports'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'documents'))) self.assertTrue(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'documents', 'MavensMate_Documents')))
def test_should_create_new_project_based_on_package_xml_file(self): package = os.path.join(base_test_directory, 'functional', 'project', 'package.xml') project_name = 'unit test project' mm_response = test_helper.create_project(self, project_name, package=package) self.assertTrue(mm_response['success'] == True) self.assertTrue(mm_response['body'] == 'Project Retrieved and Created Successfully') self.assertTrue( os.path.exists( os.path.join(base_test_directory, 'test_workspace', project_name))) self.assertTrue( os.path.exists( os.path.join(base_test_directory, 'test_workspace', project_name, 'src'))) self.assertTrue( os.path.exists( os.path.join(base_test_directory, 'test_workspace', project_name, 'src', 'classes')))
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_should_except_for_bad_package(self): package = {} mm_response = test_helper.create_project(self, "unit test project", package=package) self.assertTrue(mm_response['success'] == False) self.assertTrue(mm_response['body'] == 'Invalid package')
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_01_should_delete_trace_flags(self): test_helper.create_project(self, "unit test tooling project") stdin = {"project_name": "unit test tooling project"} mm_response = self.runCommand('delete_trace_flags', stdin) self.assertTrue(mm_response['success'] == True)