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_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.º 3
0
def edit_project(name="unit test project", package=None):
    if package is None:
        package = {"ApexClass": "*"}
    stdin = {"project_name": name, "package": package}
    request.get_request_payload = mock.Mock(return_value=stdin)
    sys.argv = ['mm.py', '-o', 'edit_project']
    MavensMateRequestHandler().execute()
    return stdin
Ejemplo n.º 4
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.º 5
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.º 6
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.º 7
0
def create_project(name="unit test project", package=None):
    if package is None:
        package = {"ApexClass": "*"}
    stdin = {
        "project_name": name,
        "username": "******",
        "password": "******",
        "org_type": "developer",
        "action": "new",
        "package": package
    }
    request.get_request_payload = mock.Mock(return_value=stdin)
    sys.argv = ['mm.py', '-o', 'new_project', '-f', 'json']
    MavensMateRequestHandler().execute()
    return stdin
Ejemplo n.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
0
 def test_05_update_project_subscription(self):
     commandOut = self.redirectStdOut()
     stdin = {
         "subscription" : ["ApexPage","ApexComponent"], 
         "project_name" : "unit test project" 
     }
     request.get_request_payload = mock.Mock(return_value=stdin)
     sys.argv = ['mm.py', '-o', 'update_subscription']
     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)
     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.º 14
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.º 15
0
def create_apex_metadata(project_name,
                         metadata_type="ApexClass",
                         api_name="unittestapexclass"):
    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": api_name,
        "project_name": project_name,
        "metadata_type": metadata_type
    }
    request.get_request_payload = mock.Mock(return_value=stdin)
    sys.argv = ['mm.py', '-o', 'new_metadata']
    MavensMateRequestHandler().execute()
Ejemplo n.º 16
0
def create_apex_metadata(project_name,
                         metadata_type="ApexClass",
                         api_name="unittestapexclass"):
    # 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"                      : api_name,
    #     "project_name"                  : project_name,
    #     "metadata_type"                 : metadata_type
    # }
    stdin = {
        'project_name': project_name,
        'metadata_type': metadata_type,
        'apex_trigger_object_api_name': None,
        'apex_class_type': None,
        'params': {
            'api_name': api_name
        },
        '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()
Ejemplo n.º 17
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.º 18
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.º 19
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.º 20
0
def compile_project(name="unit test project"):
    stdin = {"project_name": name}
    request.get_request_payload = mock.Mock(return_value=stdin)
    sys.argv = ['mm.py', '-o', 'compile_project']
    MavensMateRequestHandler().execute()
    return stdin
Ejemplo n.º 21
0
def main():
    MavensMateRequestHandler().execute()
Ejemplo n.º 22
0
def delete_apex_metadata(project_name, files=[], dirs=[]):
    stdin = {"files": files, "project_name": project_name}
    request.get_request_payload = mock.Mock(return_value=stdin)
    sys.argv = ['mm.py', '-o', 'delete']
    MavensMateRequestHandler().execute()
Ejemplo n.º 23
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)