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)
Example #2
0
 def test_03_should_try_deploy_receive_compare_result(self):
     test_helper.create_apex_metadata(self, "unit test deploy project",
                                      "ApexClass", "test_deployapexclass")
     org_connections = test_util.parse_json_from_file(
         os.path.join(self.settings['user']['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": ["test_deployapexclass"]
         },
         "debug_categories":
         ""
     }
     mm_response = self.runCommand(['mm.py', '-o', 'deploy'], stdin)
     self.assertTrue(test_helper.get_creds()['username'] in mm_response)
     self.assertTrue('unpackaged/classes/test_deployapexclass.cls' in
                     mm_response[test_helper.get_creds()['username']])
Example #3
0
 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'] == [])
Example #4
0
    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)
Example #5
0
    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'] == [])
Example #6
0
    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_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)
Example #8
0
 def test_03_should_try_deploy_receive_compare_result(self): 
     test_helper.create_apex_metadata(self, "unit test deploy project", "ApexClass", "test_deployapexclass")
     org_connections = test_util.parse_json_from_file(os.path.join(self.settings['user']['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" : ["test_deployapexclass"]
         },
         "debug_categories"  :   ""
     }
     mm_response = self.runCommand(['mm.py', '-o', 'deploy'], stdin)        
     self.assertTrue('*****@*****.**' in mm_response)
     self.assertTrue('unpackaged/classes/test_deployapexclass.cls' in mm_response['*****@*****.**'])