def test_parse_version(self):
     incorrect_versions_legacy = [
         "random_letters qwerasdfzxcv",
         "340",
         "03.4.0"
         "3.4.0.",
         "(3.4.0)",
         "3_20_20",
         ]
     
     for test_v in incorrect_versions_legacy:
         try:
             self.assertFalse(VerStruct.parse_version(test_v) != None, "VerStruct.parse_version allowed bad legacy style version %s through" % test_v)
         except Exception as e:
             pass
     
     incorrect_versions_modern = [
         "3.4.0.beta.1", #Bad separator
         "3.4.0-alpha.-1", #Int, but not < 0
         "3.4.0-rc", #Missing revision number
         "3.4.0-rc.1-1.20170906153430", #Bad separator
         "3.4.0-rc.1+1.YYYYMMDDHHMMSS", #Parsing the description, not the contents
         "3.4.0-rc.1+1.2017" #Build string is numbers, but not long enough
         ]
     
     for test_v in incorrect_versions_modern:
         try:
             self.assertFalse(VerStruct.parse_version(test_v) != None, "VerStruct.parse_version allowed bad modern style version %s through" % test_v)
         except Exception as e:
             pass
     
     correct_versions_legacy = [
         ("3.2.0", VerStruct(addon_version=(3,2,0), build_type=xplane_constants.BUILD_TYPE_LEGACY)),
         ("3.20.0",VerStruct(addon_version=(3,20,0), build_type=xplane_constants.BUILD_TYPE_LEGACY)), #Keep 20->2 in xplane_updater.py
         ("3.3.13",VerStruct(addon_version=(3,3,13),build_type=xplane_constants.BUILD_TYPE_LEGACY))
         ]
     
     for test_v, test_v_res in correct_versions_legacy:
         v_res = VerStruct.parse_version(test_v)
         self.assertTrue(v_res is not None, "VerStruct.parse_version did not allow valid legacy style version %s through" % test_v)
         self.assertTrue(test_v_res == v_res, "Test string %s did not parse to expected data %s" % (test_v,str(v_res)))
         
     correct_versions_modern = [
         ("3.4.0-rc.5+1.20170914160830",VerStruct(addon_version=(3,4,0),build_type=xplane_constants.BUILD_TYPE_RC,  build_type_version=5,
                                                    data_model_version=1,build_number="20170914160830"))
         ]
          
     for test_v, test_v_res in correct_versions_modern:
         v_res = VerStruct.parse_version(test_v)
         self.assertTrue(v_res is not None, "VerStruct.parse_version did not allow valid modern style version %s through" % test_v)
         self.assertTrue(test_v_res == v_res, "Test string %s did not parse to expected data %s" % (test_v,str(v_res)))
    def test_build_number_obj_footer(self):
        test_creation_helpers.create_datablock_collection("Layer 1")
        out = self.exportLayer(0)

        version_match = re.search("Exported with XPlane2Blender (.*)", out)
        self.assertIsNotNone(version_match,
                             "Version string not found in footer of obj")

        version = VerStruct.parse_version(version_match.group(1))
        self.assertIsNotNone(
            version, "%s could not be parsed to a valid VerStruct" %
            version_match.group(1))
        self.assertEqual(version, xplane_helpers.VerStruct.current(),
                         "Version in obj is not equal to current version")
Пример #3
0
    def test_build_number_obj_footer(self):
        bpy.ops.scene.add_xplane_layers()
        out = self.exportLayer(0)

        version_match = re.search("Exported with XPlane2Blender (.*)", out)
        self.assertTrue(version_match is not None,
                        "Version string not found in footer of obj")

        version = VerStruct.parse_version(version_match.group(1))
        self.assertTrue(
            version is not None,
            "%s could not be parsed to a valid VerStruct" %
            version_match.group(1))
        self.assertTrue(version == xplane_helpers.VerStruct.current(),
                        "Version in obj is not equal to current version")
Пример #4
0
        def try_asserts():
            current = xplane_helpers.VerStruct.current()
            self.assertTrue(
                bpy.context.scene['xplane2blender_version'] ==
                xplane_constants.DEPRECATED_XP2B_VER,
                "scene['xplane2blender_version'] was not deprecated on load")

            history = bpy.context.scene.xplane.xplane2blender_ver_history
            self.assertTrue(
                len(history) == 2,
                'xplane2blender_ver_history is %d long == not 2' %
                (len(history)))

            self.assertTrue(
                history[0].make_struct() == VerStruct.parse_version(to_parse),
                'First entry in history %s is wrong or not the legacy string' %
                str(history[0]))

            self.assertTrue(
                history[1].make_struct() == VerStruct.current(),
                'Second entry in history %s is wrong' % str(history[1]))
    def test_parse_version(self):
        incorrect_versions_legacy = [
            "random_letters qwerasdfzxcv",
            "340",
            "03.4.0"
            "3.4.0.",
            "(3.4.0)",
            "3_20_20",
        ]

        for test_v in incorrect_versions_legacy:
            try:
                self.assertFalse(
                    VerStruct.parse_version(test_v) != None,
                    "VerStruct.parse_version allowed bad legacy style version %s through"
                    % test_v)
            except Exception as e:
                pass

        incorrect_versions_modern = [
            "3.4.0.beta.1",  #Bad separator
            "3.4.0-alpha.-1",  #Int, but not < 0
            "3.4.0-rc",  #Missing revision number
            "3.4.0-rc.1-1.20170906153430",  #Bad separator
            "3.4.0-rc.1+1.YYYYMMDDHHMMSS",  #Parsing the description, not the contents
            "3.4.0-rc.1+1.2017"  #Build string is numbers, but not long enough
        ]

        for test_v in incorrect_versions_modern:
            try:
                self.assertFalse(
                    VerStruct.parse_version(test_v) != None,
                    "VerStruct.parse_version allowed bad modern style version %s through"
                    % test_v)
            except Exception as e:
                pass

        correct_versions_legacy = [
            ("3.2.0",
             VerStruct(addon_version=(3, 2, 0),
                       build_type=xplane_constants.BUILD_TYPE_LEGACY)),
            ("3.20.0",
             VerStruct(addon_version=(3, 20, 0),
                       build_type=xplane_constants.BUILD_TYPE_LEGACY)
             ),  #Keep 20->2 in xplane_updater.py
            ("3.3.13",
             VerStruct(addon_version=(3, 3, 13),
                       build_type=xplane_constants.BUILD_TYPE_LEGACY))
        ]

        for test_v, test_v_res in correct_versions_legacy:
            v_res = VerStruct.parse_version(test_v)
            self.assertTrue(
                v_res is not None,
                "VerStruct.parse_version did not allow valid legacy style version %s through"
                % test_v)
            self.assertTrue(
                test_v_res == v_res,
                "Test string %s did not parse to expected data %s" %
                (test_v, str(v_res)))

        correct_versions_modern = [
            ("3.4.0-rc.5+1.20170914160830",
             VerStruct(addon_version=(3, 4, 0),
                       build_type=xplane_constants.BUILD_TYPE_RC,
                       build_type_version=5,
                       data_model_version=1,
                       build_number="20170914160830"))
        ]

        for test_v, test_v_res in correct_versions_modern:
            v_res = VerStruct.parse_version(test_v)
            self.assertTrue(
                v_res is not None,
                "VerStruct.parse_version did not allow valid modern style version %s through"
                % test_v)
            self.assertTrue(
                test_v_res == v_res,
                "Test string %s did not parse to expected data %s" %
                (test_v, str(v_res)))
 def test_xplane2blender_str(self):
     parsed_str = str(VerStruct.parse_version('3.4.0'))
     self.assertEqual(
         "3.4.0-leg.0+0.NO_BUILD_NUMBR", parsed_str,
         "VerStruct.__str__ does not format string into proper form %s" %
         parsed_str)
    def test_rich_compare(self):
        #The following are made up and may not represent reality or the history
        # of XPlane2Blender's development
        legacy = VerStruct.parse_version('3.3.12')
        beta_4 = VerStruct.parse_version('3.4.0')
        beta_5 = VerStruct.parse_version('3.4.0-beta.5+1.NO_BUILD_NUMBR')
        rc_1_rebuild_1 = VerStruct.parse_version('3.4.0-rc.1+1.20170923121212')
        rc_1_rebuild_2 = VerStruct.parse_version('3.4.0-rc.1+1.20170924121212')
        rc_1 = VerStruct.parse_version('3.4.0-rc.1+1.NO_BUILD_NUMBR')
        rc_2 = VerStruct.parse_version('3.4.0-rc.2+2.20170922121212')
        rc_2_rebuild = VerStruct.parse_version(
            '3.4.0-rc.2+3.20170921121212'
        )  #Here the data model version has increased but was built a day before. Represents checkign out a previous commit and building from it

        ver_future_dev = VerStruct.parse_version(
            '3.4.1-dev.0+3.NO_BUILD_NUMBR')
        ver_future_alpha = VerStruct.parse_version(
            '3.4.1-alpha.1+3.20170925121212')

        self.assertTrue(
            legacy < beta_4 < beta_5 < rc_1_rebuild_1 <= rc_1_rebuild_2 <= rc_1
            < rc_2 <= rc_2_rebuild < ver_future_dev < ver_future_alpha,
            "VerStruct.__lt__ not implemented correctly")
        self.assertTrue(
            ver_future_alpha > ver_future_dev > rc_2_rebuild >= rc_2 > rc_1 >=
            rc_1_rebuild_2 >= rc_1_rebuild_1 > beta_5 > beta_4 > legacy,
            "VerStruct.__gt__ not implemented correctly")

        legacy_copy = VerStruct.parse_version('3.3.12')
        self.assertTrue(legacy == legacy_copy,
                        "VerStruct.__eq__ not implemented correctly")
        self.assertTrue(legacy != beta_4,
                        "VerStruct.__ne__ not implemented correctly")
 def test_xplane2blender_str(self):
     parsed_str = str(VerStruct.parse_version('3.4.0'))
     self.assertEqual("3.4.0-leg.0+0.NO_BUILD_NUMBR", parsed_str, "VerStruct.__str__ does not format string into proper form %s" % parsed_str)
    def test_rich_compare(self):
        #The following are made up and may not represent reality or the history
        # of XPlane2Blender's development
        legacy = VerStruct.parse_version('3.3.12')
        beta_4 = VerStruct.parse_version('3.4.0')
        beta_5 = VerStruct.parse_version('3.4.0-beta.5+1.NO_BUILD_NUMBR')
        rc_1_rebuild_1 = VerStruct.parse_version('3.4.0-rc.1+1.20170923121212')
        rc_1_rebuild_2 = VerStruct.parse_version('3.4.0-rc.1+1.20170924121212')
        rc_1 = VerStruct.parse_version('3.4.0-rc.1+1.NO_BUILD_NUMBR')
        rc_2 = VerStruct.parse_version('3.4.0-rc.2+2.20170922121212')
        rc_2_rebuild = VerStruct.parse_version('3.4.0-rc.2+3.20170921121212') #Here the data model version has increased but was built a day before. Represents checkign out a previous commit and building from it

        ver_future_dev = VerStruct.parse_version('3.4.1-dev.0+3.NO_BUILD_NUMBR')
        ver_future_alpha = VerStruct.parse_version('3.4.1-alpha.1+3.20170925121212')
        
        self.assertTrue(legacy < beta_4 < beta_5 < rc_1_rebuild_1 <= rc_1_rebuild_2 <= rc_1 < rc_2 <= rc_2_rebuild < ver_future_dev < ver_future_alpha,
                         "VerStruct.__lt__ not implemented correctly")
        self.assertTrue(ver_future_alpha > ver_future_dev > rc_2_rebuild >= rc_2 > rc_1 >= rc_1_rebuild_2 >= rc_1_rebuild_1 > beta_5 > beta_4 > legacy,
                         "VerStruct.__gt__ not implemented correctly")

        legacy_copy = VerStruct.parse_version('3.3.12')
        self.assertTrue(legacy == legacy_copy, "VerStruct.__eq__ not implemented correctly")
        self.assertTrue(legacy != beta_4, "VerStruct.__ne__ not implemented correctly")