Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MercuryiTC IOC: update pattern for TEMP/LEVEL/PRESSURE macros #7322

Closed
2 tasks
boeuf-codes opened this issue Sep 2, 2022 · 2 comments
Closed
2 tasks

MercuryiTC IOC: update pattern for TEMP/LEVEL/PRESSURE macros #7322

boeuf-codes opened this issue Sep 2, 2022 · 2 comments
Assignees

Comments

@boeuf-codes
Copy link
Contributor

Where?

See \\ioc\master\MERCURY_ITC\iocBoot\iocMERCURY-IOC-01.

As of writing this issue, all MercuryiTC TEMP, LEVEL and PRESSURE macros (not ones with the old VI_... prefix) have values in the format letters.letters (I will comment a test to be able to check this is still the case). This format is also shared by Newport XPS-D controllers.

However, the regex pattern for MercuryiTC is ^.*$, which is exactly anything, whereas for Newport XPS-D it is ^.*[.].*$, which describes the pattern specified above.

Therefore, it seems sensible to update the pattern values for MercuryiTC TEMP, LEVEL and PRESSURE macros.

Acceptance criteria

  • Rectify the regex patterns for TEMP, LEVEL and PRESSURE macros to ^.*[.].*$
  • No TEMP, LEVEL and PRESSURE macro values mismatch this pattern after the change

How to Test

verbose instructions for reviewer to test changes
(Add before making a PR)

@boeuf-codes
Copy link
Contributor Author

boeuf-codes commented Sep 2, 2022

ConfigChecker test for checking macro value pattern match:
(Written in config tests but just refactor where needed for component)

@parameterized.expand(
        [("MERCURY_{:02d}".format(i), "TEMPERATURE/LEVEL/PRESSURE", "^(TEMP_[1-4]|LEVEL_[1-2]|PRESSURE_[1-2])$", "^.*[.].*$") for i in range(1, 3)]
    )
    def test_WHEN_a_config_has_a_mercury_THEN_get_its_pattern(self, ioc, macro_name, macro_regex, value_regex):
        iocs_xml = self.config_utils.get_iocs_xml(self.config)
        iocs = self.config_utils.get_iocs(iocs_xml)
        
        if ioc in iocs:
            config_macros = self.config_utils.check_if_macros_match_pattern(self.config_utils.get_ioc_macros(iocs_xml, ioc), macro_regex, search_for_value=False)
            globals_macros = self.config_utils.check_if_macros_match_pattern(self.global_utils.get_macros(ioc), macro_regex, search_for_value=False)

            invalid_macros = dict([(name,value) for d in (config_macros, globals_macros) for name,value in d.items() if not re.search(value_regex, value)])
            self.assertTrue(len(invalid_macros)==0, "Macro(s) not matching ^.*[.].*$ found in {} in config {}: {}".format(ioc, self.config, str(invalid_macros)))

@boeuf-codes
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants