Exemple #1
0
    def test_validate_workspace_params_happy_path(self):
        fileutils = MockFileUtils()

        workspace_dir = '/home/abracadabra/IdeaProjects/rest-workspace'
        jira_project_dir = 'jira-project'
        pom_xml = 'pom.xml'

        fileutils.default_getcwd(os.sep.join([workspace_dir, jira_project_dir]))
        fileutils.expect_file_exists(os.sep.join([workspace_dir, pom_xml]), toReturn=True)
        fileutils.expect_get_parent_dir_path(toReturn=workspace_dir)

        callable_status = WorkspaceValidator(fileutils)(Mock())

        self.assertEqual(callable_status, Callable.success)
Exemple #2
0
    def test_transform_maven_executable_for_workspace(self):
        fileutils = MockFileUtils()

        workspace_dir = '/home/abracadabra/IdeaProjects/rest-workspace'
        jira_project_dir = 'jira-project'
        jira_rest_dir = 'jira-rest'
        pom_xml = 'pom.xml'

        fileutils.expect_get_parent_dir_relpath(workspace_dir, toReturn=jira_project_dir)

        fileutils.default_getcwd(os.sep.join([workspace_dir, jira_project_dir]))
        fileutils.expect_listdir(workspace_dir,
                                 toReturn=[jira_project_dir, jira_rest_dir, '.idea', pom_xml, 'README.txt'])

        fileutils.expect_dir_exists(os.sep.join([workspace_dir, jira_project_dir]), toReturn=True)
        fileutils.expect_dir_exists(os.sep.join([workspace_dir, jira_rest_dir]), toReturn=True)
        fileutils.expect_dir_exists(os.sep.join([workspace_dir, '.idea']), toReturn=True)

        fileutils.expect_file_exists(os.sep.join([workspace_dir, jira_project_dir, pom_xml]), toReturn=True)
        fileutils.expect_file_exists(os.sep.join([workspace_dir, jira_rest_dir, pom_xml]), toReturn=True)

        parser_mocks = {os.sep.join([workspace_dir, jira_project_dir, pom_xml]):
                            Mock().expect_get_artifact_id(toReturn=jira_project_dir).expect_get_version(toReturn='10.0.0-SNAPSHOT'),
                        os.sep.join([workspace_dir, jira_rest_dir, pom_xml]):
                            Mock().expect_get_artifact_id(toReturn=jira_rest_dir).expect_get_version(toReturn='9.1.2-SNAPSHOT')}

        PROJECT1 = os.sep.join(['jira-components', 'jira-webapp'])
        PROJECT2 = os.sep.join(['jira-components', 'jira-plugins', 'jira-bundled-plugins'])
        maven_mock = Mock(projects = [PROJECT1, PROJECT2])

        MavenCallableWorkspaceDelegator.after_init(maven_mock, workspace_dir, fileutils,
                                                   pom_parser_class_object=lambda path: parser_mocks[path])

        for k, v in {'jira.version': '10.0.0-SNAPSHOT',
                     'jira.project.version': '10.0.0-SNAPSHOT',
                     'jira.rest.version': '9.1.2-SNAPSHOT'}.items():
            self.assertTrue(maven_mock.verify_property(k, v))