コード例 #1
0
    def setUp(self):
        super(ModuleCreatorVerifyRemoteRepoTest, self).setUp()

        self.mock_is_server_repo = set_up_mock(
            self, 'dls_ade.gitlabserver.GitlabServer.is_server_repo')

        self.nmc_obj = mc.ModuleCreator("test_module", "test_area",
                                        MagicMock())

        self.nmc_obj._remote_repo_valid = False
コード例 #2
0
    def setUp(self):
        super(ModuleCreatorVerifyCanCreateLocalModule, self).setUp()

        self.mock_exists = set_up_mock(
            self, 'dls_ade.module_creator.os.path.exists')
        self.mock_is_in_local_repo = set_up_mock(
            self, 'dls_ade.module_creator.vcs_git.is_in_local_repo')

        self.nmc_obj = mc.ModuleCreator("test_module", "test_area",
                                        MagicMock())

        self.nmc_obj._can_create_local_module = False
コード例 #3
0
    def test_given_no_extra_template_args_then_module_template_initialisation_includes_expected_keys(
            self):

        expected_dict = {
            'module_name': "test_module",
            'module_path': "test_module",
            'user_login': "******",
            'full_name': "Name",
            'email': "*****@*****.**"
        }

        base_c = mc.ModuleCreator("test_module", "test_area", self.mock_mt)

        self.mock_mt.assert_called_once_with(expected_dict)
コード例 #4
0
    def setUp(self):
        super(ModuleCreatorVerifyCanPushLocalRepoToRemoteTest, self).setUp()

        self.mock_exists = set_up_mock(
            self, 'dls_ade.module_creator.os.path.exists')
        self.mock_is_local_repo_root = set_up_mock(
            self, 'dls_ade.module_creator.vcs_git.is_local_repo_root')
        self.mock_verify_remote_repo = set_up_mock(
            self, 'dls_ade.module_creator.ModuleCreator.verify_remote_repo')

        self.nmc_obj = mc.ModuleCreator("test_module", "test_area",
                                        MagicMock())

        self.nmc_obj._can_push_repo_to_remote = False
コード例 #5
0
    def setUp(self):
        super(ModuleCreatorPushRepoToRemoteTest, self).setUp()

        self.mock_verify_can_push_repo_to_remote = set_up_mock(
            self,
            'dls_ade.module_creator.ModuleCreator.verify_can_push_repo_to_remote'
        )
        self.mock_add_new_remote_and_push = set_up_mock(
            self, 'dls_ade.module_creator.vcs_git.Git.add_new_remote_and_push')

        self.nmc_obj = mc.ModuleCreator("test_module", "test_area",
                                        MagicMock())
        self.server_mock = MagicMock()
        self.vcs_mock = MagicMock()
        self.server_mock.create_new_local_repo.return_value = self.vcs_mock
        self.nmc_obj.server = self.server_mock
コード例 #6
0
    def setUp(self):
        super(ModuleCreatorCreateLocalModuleTest, self).setUp()

        self.mock_os = set_up_mock(self, 'dls_ade.module_creator.os')
        self.mock_vcs_git = set_up_mock(self, 'dls_ade.module_creator.vcs_git')
        self.mock_verify_can_create_local_module = set_up_mock(
            self,
            'dls_ade.module_creator.ModuleCreator.verify_can_create_local_module'
        )

        self.mock_module_template_cls = MagicMock()
        self.mock_module_template = MagicMock()
        self.mock_module_template_cls.return_value = self.mock_module_template
        self.mock_create_files = self.mock_module_template.create_files

        self.nmc_obj = mc.ModuleCreator("test_module", "test_area",
                                        self.mock_module_template_cls)
コード例 #7
0
def get_module_creator(module_name, area="support", fullname=False):
    """Returns a :class:`ModuleCreator` subclass object.

    Returns an object of a subclass of :class:`ModuleCreator`, depending on
    the arguments given.

    Supported areas are:
        - Python
        - Support
        - Tools
        - IOC

    Python module name format:
        - Must begin with `dls_`
        - Must not have any hyphens ("-") or full stops (".")

    IOC module name format:
        New-Style module (preferred):
            Format: "BL02I-VA-IOC-03"
                "<beamline>-<technical_area>-IOC-<ioc_number>"
            Alternative: "BL02I/VA/03", with fullname = True
                "<beamline>/<technical_area>/<ioc_number>", fullname = True

            If the alternative is used, if the IOC number is omitted
            (eg. <beamline>/<technical_area>) it defaults to "01"

        Old-Style module (deprecated, except for BL modules):
            Format: "BL02I/VA/03", with fullname = False (or omitted)
                "<beamline>/<technical_area>/<ioc_number>"

    Args:
        module_name: The name of the module.
        area: The area of the module.
        fullname: Create new-style module from old-style input.
            If True and module_name given in old-style format, then a
            new-style module is created.

    Returns:
        ModuleCreator: An object of a :class:`ModuleCreator` subclass

    Raises:
        ParsingError: If an IOC module name cannot be split by '-' or '/'.
        ParsingError: If the Python module name is not properly constructed.
        ParsingError: If the area given is not supported.

    """
    if area == "ioc":
        return get_module_creator_ioc(module_name, fullname)

    elif area in ("python", "python3"):
        valid_name = re.match("[a-zA-Z][a-zA-Z_0-9]*$", module_name)
        if not valid_name:
            raise ParsingError(
                "Python module names must be valid python identifiers")

        template = (mt.ModuleTemplatePython
                    if area == "python" else mt.ModuleTemplatePython3)
        return mc.ModuleCreator(module_name, area, template)

    elif area == "support":
        return mc.ModuleCreatorWithApps(module_name,
                                        area,
                                        mt.ModuleTemplateSupport,
                                        app_name=module_name)

    elif area == "tools":
        return mc.ModuleCreator(module_name, area, mt.ModuleTemplateTools)

    elif area == "matlab":
        return mc.ModuleCreator(module_name, area, mt.ModuleTemplateMatlab)

    else:
        raise ParsingError("Don't know how to make a module of type: " + area)
コード例 #8
0
    def test_given_reasonable_input_then_initialisation_is_successful(self):

        mc.ModuleCreator("test_module", "test_area", self.mock_mt)
コード例 #9
0
    def setUp(self):
        super(ModuleCreatorPrintMessageTest, self).setUp()

        self.mock_module_template = MagicMock()
        self.nmc_obj = mc.ModuleCreator("test_module", "test_area",
                                        self.mock_module_template)