Beispiel #1
0
 def get_gui_repo_at_release(self, version):
     version = VersionUtils.extract_release_numbers_from_string(version)
     branch_name = VersionUtils.convert_release_to_tag_name(*version)
     if not self.git.update_branch(branch_name, True):
         raise IOError(
             "Couldn't check out GUI branch corresponding to release {}".
             format(version))
Beispiel #2
0
def setup_instrument_tests(instrument):
    """
    Sets up the settings class and configurations repository to point at the given instrument.

    :param instrument: A dictionary representing the properties of an instrument as per the CS:INSTLIST PV.
    :return: True if successful, False otherwise.
    """
    name, hostname, pv_prefix = instrument['name'], instrument[
        'hostName'], instrument['pvPrefix']
    try:
        Settings.set_instrument(name, hostname, pv_prefix)
    except Exception:
        print("Unable to set instrument to {} because {}".format(
            name, traceback.format_exc()))
        return False

    print("\n\nChecking out git repository for {} ({})...".format(
        name, hostname))
    config_repo_update_successful = GitUtils(
        Settings.config_repo_path).update_branch(hostname)

    version_utils = VersionUtils(Settings.config_repo_path)

    if version_utils.version_file_exists():
        GuiUtils(Settings.gui_repo_path).get_gui_repo_at_release(
            version_utils.get_version())
    else:
        print("Warning: could not determine GUI version for instrument {}".
              format(instrument))
    return config_repo_update_successful
Beispiel #3
0
    def test_GIVEN_two_identical_versions_WHEN_checking_if_they_are_similar_THEN_result_is_true(
            self):
        # Arrange
        version1 = "4.0.0"
        version2 = "4.0.0"

        # Act / Assert
        self.assertTrue(VersionUtils.versions_similar(version1, version2))
        self.assertTrue(VersionUtils.versions_similar(version2, version1))
Beispiel #4
0
    def test_GIVEN_only_patch_version_is_different_WHEN_checking_if_they_are_similar_THEN_result_is_false(
            self):
        # Arrange
        version1 = "4.0.0"
        version2 = "4.0.2"

        # Act / Assert
        self.assertFalse(VersionUtils.versions_similar(version1, version2))
        self.assertFalse(VersionUtils.versions_similar(version2, version1))
Beispiel #5
0
    def test_GIVEN_two_different_versions_where_one_has_a_checksum_appended_WHEN_checking_if_they_are_similar_THEN_result_is_false(
            self):
        # Arrange
        version1 = "4.0.0"
        version2 = "3.0.0.abc123abc"

        # Act / Assert
        self.assertFalse(VersionUtils.versions_similar(version1, version2))
        self.assertFalse(VersionUtils.versions_similar(version2, version1))
Beispiel #6
0
    def test_GIVEN_a_1_level_version_WHEN_construct_release_branch_name_THEN_appropriate(
            self):
        # Arrange
        major = 3

        # Act
        branchname = VersionUtils.convert_release_to_tag_name(major)

        # Assert
        self.assertEqual(branchname, "v3.0.0")
Beispiel #7
0
    def test_GIVEN_a_2_level_version_in_a_string_THEN_arguments_extracted_appropriately(
            self):
        # Arrange
        version = "3.2"

        # Act
        major, minor = VersionUtils.extract_release_numbers_from_string(
            version)

        # Assert
        self.assertEqual(3, int(major))
        self.assertEqual(2, int(minor))
class VersionTests(unittest.TestCase):
    def setUp(self):
        self.version_utils = VersionUtils(Settings.config_repo_path)
        self.ca = ChannelAccessUtils(Settings.pv_prefix)

    def test_WHEN_looking_for_config_version_file_THEN_it_exists(self):
        self.assertTrue(self.version_utils.version_file_exists(),
                        "Config version file did not exist")

    def test_WHEN_counting_config_version_files_in_repository_THEN_there_is_exactly_one_file(
            self):
        self.assertLessEqual(
            self.version_utils.count_config_version_files(), 1,
            "There should not be more than one '{}' file in the repository.".
            format(VersionUtils.VERSION_FILE))

    @skip_on_instruments(
        ["DEMO"], "DEMO does not typically have a full release installed")
    def test_GIVEN_version_file_exists_THEN_it_is_the_same_as_version_pv_on_server(
            self):
        if not self.version_utils.version_file_exists():
            self.skipTest("Version file did not exist.")

        config_version = self.version_utils.get_version()
        server_version = self.ca.get_version_string()

        if server_version is None:
            self.skipTest("Couldn't connect to version PV on server")

        if (Settings.name == "POLREF" or Settings.name
                == "CRISP") and server_version.startswith("7.2.0"):
            self.skipTest("Reflectometry reverted to 7.2.0 due to #6472")

        # Special case for server version 0.0.0 which is a development release - assume it's always up to date.
        if not server_version.startswith("0.0.0"):
            self.assertTrue(
                self.version_utils.versions_similar(config_version,
                                                    server_version),
                "Config version was wrong. Server version={}, config version={}"
                .format(server_version, config_version))
Beispiel #9
0
    def test_GIVEN_a_3_level_version_WHEN_construct_release_branch_name_THEN_appropriate(
            self):
        # Arrange
        major = 3
        minor = 2
        patch = 1

        # Act
        branchname = VersionUtils.convert_release_to_tag_name(
            major, minor, patch)

        # Assert
        self.assertEqual(branchname, "v3.2.1")
Beispiel #10
0
    def test_GIVEN_a_3_level_version_with_a_checksum_in_a_string_THEN_arguments_extracted_appropriately(
            self):
        # Arrange
        version = "3.2.1.abc123abc"

        # Act
        major, minor, patch = VersionUtils.extract_release_numbers_from_string(
            version)

        # Assert
        self.assertEqual(3, int(major))
        self.assertEqual(2, int(minor))
        self.assertEqual(1, int(patch))
 def setUp(self):
     self.version_utils = VersionUtils(Settings.config_repo_path)
     self.ca = ChannelAccessUtils(Settings.pv_prefix)