Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    def runCommand(self, command_name_or_argv, stdin, as_json=True, print_before_deserialization=True, **kwargs):
        commandOut = self.redirectStdOut()
        request.get_request_payload = mock.Mock(return_value=stdin)
        if type(command_name_or_argv) is list:
            sys.argv = command_name_or_argv
        else:
            return_format = kwargs.get('return_format', 'json')
            sys.argv = ['mm.py', '-o', command_name_or_argv, '-f', return_format]
        
        MavensMateRequestHandler().execute()
        mm_response = commandOut.getvalue()

        sys.stdout = self.saved_stdout

        if print_before_deserialization:
            if type(command_name_or_argv) is list:
                print '\n\n['+str(command_name_or_argv[2])+'] ------->\n'
            else:
                print '\n\n['+str(command_name_or_argv)+'] ------->\n'

            print '\n[STDIN] -->\n'
            if type(stdin) is str:
                print stdin
            elif type(stdin) is dict or type(stdin) is list and stdin != {}:
                print json.dumps(stdin)
            print '\n[STDOUT] -->\n'
            print mm_response
        if as_json:
            mm_response = util.parse_mm_response(mm_response)
        return mm_response
Ejemplo n.º 5
0
 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"] == "[]")
Ejemplo n.º 6
0
 def test_03_update_debug_settings(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "project_name"      : "unit test tooling project",
         "debug_categories"  : {
             "Workflow"      : "FINE", 
             "Callout"       : "FINE", 
             "System"        : "FINE", 
             "Database"      : "FINE", 
             "ApexCode"      : "FINE", 
             "Validation"    : "FINE", 
             "Visualforce"   : "FINE"
         },
         "expiration"        : 120
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'update_debug_settings']
     mm.main()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     #print mm_response
     mm_json_response = util.parse_mm_response(mm_response)
     new_debug_settings = util.parse_json_file(os.path.join(base_test_directory, "test_workspace", stdin["project_name"], "config", ".debug"))
     self.assertTrue(new_debug_settings['expiration'] == stdin["expiration"])
     self.assertTrue(new_debug_settings['levels']['Workflow'] == stdin["debug_categories"]["Workflow"])
     self.assertTrue(new_debug_settings['levels']['Visualforce'] == stdin["debug_categories"]["Visualforce"])
Ejemplo n.º 7
0
    def test_02_bad_compile(self):
        client_settings = mmutil.parse_json_from_file(
            os.path.join(test_helper.base_test_directory,
                         "user_client_settings.json"))
        commandOut = self.redirectStdOut()
        src = open(
            os.path.join(client_settings["mm_workspace"],
                         "unit test metadata project", "src", "classes",
                         "unittestapexclass.cls"), "w")
        src.write(
            'public class unittestapexclass { public unittestapexclass() { String foo } }'
        )
        src.close()

        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'] == 'Failed')
        commandOut = self.redirectStdOut()
        test_helper.delete_apex_metadata("unit test metadata project", [
            os.path.join(client_settings["mm_workspace"],
                         "unit test metadata project", "src", "classes",
                         "unittestapexclass.cls")
        ])
Ejemplo n.º 8
0
 def test_05_update_debug_settings(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "project_name"      : "unit test tooling project",
         "debug_categories"  : {
             "Workflow"      : "FINE", 
             "Callout"       : "FINE", 
             "System"        : "FINE", 
             "Database"      : "FINE", 
             "ApexCode"      : "FINE", 
             "Validation"    : "FINE", 
             "Visualforce"   : "FINE"
         },
         "expiration"        : 120
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'update_debug_settings']
     MavensMateRequestHandler().execute()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     print mm_response
     mm_json_response = util.parse_mm_response(mm_response)
     new_debug_settings = util.parse_json_file(os.path.join(base_test_directory, "test_workspace", stdin["project_name"], "config", ".debug"))
     self.assertTrue(new_debug_settings['expiration'] == stdin["expiration"])
     self.assertTrue(new_debug_settings['levels']['Workflow'] == stdin["debug_categories"]["Workflow"])
     self.assertTrue(new_debug_settings['levels']['Visualforce'] == stdin["debug_categories"]["Visualforce"])
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
    def test_03_delete_apex_class(self):
        commandOut = self.redirectStdOut()
        client_settings = mmutil.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 metadata project",
                    "src",
                    "classes",
                    "unittestapexclass.cls",
                )
            ],
            "project_name": "unit test metadata 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 = test_util.parse_mm_response(mm_response)
        self.assertTrue(mm_json_response["success"] == True)
Ejemplo n.º 11
0
 def test_project_ui(self):
     stdin = {}
     sys.argv = ['mm.py', '-o', 'new_project', '--ui']
     self.set_stdin(stdin)
     mm.main()
     mm_response = self.output.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     print mm_json_response
     self.assertTrue(mm_json_response['success'] == True)
Ejemplo n.º 12
0
 def test_04_compile_project(self):
     stdin = test_helper.compile_project("unit test project")
     mm_response = self.output.getvalue()
     mm_json_response = util.parse_mm_response(mm_response)
     sys.stdout = self.saved_stdout
     self.assertTrue(mm_json_response['success'] == True)
     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', 'package.xml')))
Ejemplo n.º 13
0
 def test_02_edit_project(self): 
     stdin = test_helper.edit_project("unit test project", package={ "ApexClass" : "*" } )
     mm_response = self.output.getvalue()
     mm_json_response = util.parse_mm_response(mm_response)
     sys.stdout = self.saved_stdout
     self.assertTrue(mm_json_response['success'] == True)
     self.assertTrue(mm_json_response['body'] == 'Project Edited 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.assertFalse(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'pages')))
Ejemplo n.º 14
0
 def test_02_get_active_session_bad_request(self):
     commandOut = self.redirectStdOut()
     stdin = {"username": "******"}
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_active_session']
     MavensMateRequestHandler().execute()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     self.assertTrue(mm_json_response['success'] == False)
     self.assertTrue(mm_json_response['body'] ==
                     "Please enter a Salesforce.com password")
Ejemplo n.º 15
0
 def test_04_compile_project(self):
     stdin = {
         "project_name"  : "unit test project"
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'compile_project']
     mm.main()
     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)
Ejemplo n.º 16
0
 def test_06_fetch_logs(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "project_name"      : "unit test tooling project"
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'fetch_logs']
     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)
Ejemplo n.º 17
0
 def test_02_get_active_session_bad_request(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "username" : "*****@*****.**"
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_active_session']
     mm.main()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     self.assertTrue(mm_json_response['success'] == False)
     self.assertTrue(mm_json_response['body'] == "Please enter a Salesforce.com password")
Ejemplo n.º 18
0
Archivo: cli.py Proyecto: akshayas/mm
 def test_bad_operation_name(self): 
     stdin = {
         "project_name" : "bloat"
     }
     sys.argv = ['mm.py', '-o', 'new_project_bad', '--ui']
     self.set_stdin(stdin)
     mm.main()
     mm_response = self.output.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     print mm_json_response
     self.assertTrue(mm_json_response['success'] == False)
     self.assertTrue(mm_json_response['body'] == 'Unsupported operation')
Ejemplo n.º 19
0
 def test_03_clean_project(self):
     stdin = test_helper.clean_project("unit test project")
     mm_response = self.output.getvalue()
     mm_json_response = util.parse_mm_response(mm_response)
     sys.stdout = self.saved_stdout
     self.assertTrue(mm_json_response['success'] == True)
     self.assertTrue(mm_json_response['body'] == 'Project Cleaned 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.assertFalse(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'pages')))
     self.assertFalse(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'reports')))
     self.assertFalse(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'documents')))
Ejemplo n.º 20
0
    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)
Ejemplo n.º 21
0
 def test_04_get_trace_flags(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "project_name"      : "unit test tooling project"
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_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['totalSize'] == 2)
     self.assertTrue(mm_json_response['entityTypeName'] == 'TraceFlag')
     self.assertTrue(mm_json_response['done'] == True)
Ejemplo n.º 22
0
 def test_01_get_active_session_bad_creds(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "username" : "*****@*****.**",
         "password" : "forceee",
         "org_type" : "developer"
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_active_session']
     mm.main()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     self.assertTrue(mm_json_response['success'] == False)
     self.assertTrue(mm_json_response['body'] == "Server raised fault: 'INVALID_LOGIN: Invalid username, password, security token; or user locked out.'")
Ejemplo n.º 23
0
 def test_03_get_active_session_good_creds(self):
     commandOut = self.redirectStdOut()
     stdin = {
         "username": "******",
         "password": "******",
         "org_type": "developer"
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_active_session']
     MavensMateRequestHandler().execute()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     print mm_json_response
     self.assertTrue(mm_json_response['success'] == True)
     self.assertTrue(len(mm_json_response['user_id']) is 18)
Ejemplo n.º 24
0
 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")
Ejemplo n.º 25
0
    def test_02_delete_apex_class(self): 
        commandOut = self.redirectStdOut()
        client_settings = mm_util.parse_json_from_file(os.path.join(base_test_directory, "user_client_settings.json"))
        stdin = {
            "files": [os.path.join(client_settings["mm_workspace"],"unit test metadata project","src","classes","unittestapexclass.cls")], 
            "project_name": "unit test metadata project"
        }

        mm_util.get_request_payload = mock.Mock(return_value=stdin)
        sys.argv = ['mm.py', '-o', 'delete']
        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)
Ejemplo n.º 26
0
 def test_03_get_active_session_good_creds(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "username" : "*****@*****.**",
         "password" : "force",
         "org_type" : "developer"
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_active_session']
     mm.main()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     print mm_json_response
     self.assertTrue(mm_json_response['success'] == True)
     self.assertTrue(len(mm_json_response['user_id']) is 18)
Ejemplo n.º 27
0
 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)
Ejemplo n.º 28
0
 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')
Ejemplo n.º 29
0
 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")
Ejemplo n.º 30
0
 def test_03_clean_project(self):
     stdin = {
         "project_name"  : "unit test project"
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'clean_project']
     mm.main()
     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 Cleaned 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.assertFalse(os.path.exists(os.path.join(base_test_directory, 'test_workspace', stdin['project_name'], 'src', 'pages')))
Ejemplo n.º 31
0
 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)
Ejemplo n.º 32
0
 def test_05_update_project_subscription(self):
     commandOut = self.redirectStdOut()
     stdin = {
         "subscription" : ["ApexPage","ApexComponent"], 
         "project_name" : "unit test project" 
     }
     mm_util.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'update_subscription']
     mm.main()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     self.assertTrue(mm_json_response['success'] == True)
     project_settings = util.parse_json_file(os.path.join(base_test_directory, 'test_workspace', 'unit test project', 'config', '.settings'))
     self.assertTrue(type(project_settings['subscription']) is list and len(project_settings['subscription']) == 2)
     self.assertTrue(project_settings['subscription'][0] == "ApexPage")
     self.assertTrue(project_settings['subscription'][1] == "ApexComponent")
Ejemplo n.º 33
0
 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')
Ejemplo n.º 34
0
 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)
Ejemplo n.º 35
0
 def test_01_get_active_session_bad_creds(self):
     commandOut = self.redirectStdOut()
     stdin = {
         "username": "******",
         "password": "******",
         "org_type": "developer"
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'get_active_session']
     MavensMateRequestHandler().execute()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     mm_json_response = util.parse_mm_response(mm_response)
     self.assertTrue(mm_json_response['success'] == False)
     self.assertTrue(
         mm_json_response['body'] ==
         "Server raised fault: 'INVALID_LOGIN: Invalid username, password, security token; or user locked out.'"
     )
Ejemplo n.º 36
0
    def test_02_bad_compile(self):
        client_settings = mmutil.parse_json_from_file(
            os.path.join(test_helper.base_test_directory, "user_client_settings.json")
        )
        commandOut = self.redirectStdOut()
        src = open(
            os.path.join(
                client_settings["mm_workspace"], "unit test metadata project", "src", "classes", "unittestapexclass.cls"
            ),
            "w",
        )
        src.write("public class unittestapexclass { public unittestapexclass() { String foo } }")
        src.close()

        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"] == "Failed")
        commandOut = self.redirectStdOut()
        test_helper.delete_apex_metadata(
            "unit test metadata project",
            [
                os.path.join(
                    client_settings["mm_workspace"],
                    "unit test metadata project",
                    "src",
                    "classes",
                    "unittestapexclass.cls",
                )
            ],
        )
Ejemplo n.º 37
0
 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'] == '[]')
Ejemplo n.º 38
0
 def test_02_new_quicklog(self): 
     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_quick_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('1 Log(s) created successfully' in mm_json_response['body'])
Ejemplo n.º 39
0
 def test_02_new_debug_log(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "project_name"      : "unit test tooling project",
         "type"              : "user",
         "debug_categories"  : {
             "ApexCode"      : "DEBUG",
             "Visualforce"   : "INFO"
         }
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'new_log']
     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)
Ejemplo n.º 40
0
 def runCommand(self, command_name_or_argv, stdin, as_json=True, print_before_deserialization=True):
     commandOut = self.redirectStdOut()
     request.get_request_payload = mock.Mock(return_value=stdin)
     if type(command_name_or_argv) is list:
         sys.argv = command_name_or_argv
     else:
         sys.argv = ['mm.py', '-o', command_name_or_argv]
     MavensMateRequestHandler().execute()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     if print_before_deserialization:
         if type(command_name_or_argv) is list:
             print '['+str(command_name_or_argv[2])+'] ------->'
         else:
             print '['+str(command_name_or_argv)+'] ------->'
         print mm_response
     if as_json:
         mm_response = util.parse_mm_response(mm_response)
     return mm_response
Ejemplo n.º 41
0
 def test_03_new_quicklog(self): 
     commandOut = self.redirectStdOut()
     stdin = {
         "project_name"      : "unit test tooling project",
         "type"              : "user",
         "debug_categories"  : {
             "ApexCode"      : "DEBUG",
             "Visualforce"   : "INFO"
         }
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'new_quick_log']
     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('1 Log(s) created successfully' in mm_json_response['body'])
Ejemplo n.º 42
0
 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')))
Ejemplo n.º 43
0
 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": "DEBUG"
         }
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'new_log']
     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)
Ejemplo n.º 44
0
 def runCommand(self,
                command_name_or_argv,
                stdin,
                as_json=True,
                print_before_deserialization=True):
     commandOut = self.redirectStdOut()
     request.get_request_payload = mock.Mock(return_value=stdin)
     if type(command_name_or_argv) is list:
         sys.argv = command_name_or_argv
     else:
         sys.argv = ['mm.py', '-o', command_name_or_argv]
     MavensMateRequestHandler().execute()
     mm_response = commandOut.getvalue()
     sys.stdout = self.saved_stdout
     if print_before_deserialization:
         if type(command_name_or_argv) is list:
             print '[' + str(command_name_or_argv[2]) + '] ------->'
         else:
             print '[' + str(command_name_or_argv) + '] ------->'
         print mm_response
     if as_json:
         mm_response = util.parse_mm_response(mm_response)
     return mm_response
Ejemplo n.º 45
0
    def test_03_delete_apex_class(self):
        commandOut = self.redirectStdOut()
        client_settings = mmutil.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 metadata project", "src", "classes",
                             "unittestapexclass.cls")
            ],
            "project_name":
            "unit test metadata 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 = test_util.parse_mm_response(mm_response)
        self.assertTrue(mm_json_response['success'] == True)
Ejemplo n.º 46
0
    def runCommand(self,
                   command_name_or_argv,
                   stdin,
                   as_json=True,
                   print_before_deserialization=True,
                   **kwargs):
        commandOut = self.redirectStdOut()
        request.get_request_payload = mock.Mock(return_value=stdin)
        if type(command_name_or_argv) is list:
            sys.argv = command_name_or_argv
        else:
            return_format = kwargs.get('return_format', 'json')
            sys.argv = [
                'mm.py', '-o', command_name_or_argv, '-f', return_format
            ]

        MavensMateRequestHandler().execute()
        mm_response = commandOut.getvalue()

        sys.stdout = self.saved_stdout

        if print_before_deserialization:
            if type(command_name_or_argv) is list:
                print '\n\n[' + str(command_name_or_argv[2]) + '] ------->\n'
            else:
                print '\n\n[' + str(command_name_or_argv) + '] ------->\n'

            print '\n[STDIN] -->\n'
            if type(stdin) is str:
                print stdin
            elif type(stdin) is dict or type(stdin) is list and stdin != {}:
                print json.dumps(stdin)
            print '\n[STDOUT] -->\n'
            print mm_response
        if as_json:
            mm_response = util.parse_mm_response(mm_response)
        return mm_response
Ejemplo n.º 47
0
    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)