示例#1
0
    def test_minimum_version(self):
        """
        Tests the min required frameworks for an app
        """
        app = self.engine.apps["test_app"]
        previous_mins = dict()
        frameworks = app.descriptor.required_frameworks

        for fw in frameworks:
            previous_mins[fw["name"]] = fw.get("minimum_version")
            fw["minimum_version"] = "v999.999.999"

        try:
            # We should get an error here due to the too-high
            # minumum required version for the frameworks.
            self.assertRaises(
                TankError,
                validation.validate_and_return_frameworks,
                app.descriptor,
                self.engine.get_env(),
            )

            for fw in frameworks:
                fw["minimum_version"] = "v0.0.0"

            # We should get back a list of framework objects that
            # is the same length as the number of required frameworks
            # we have.
            self.assertEqual(
                len(
                    validation.validate_and_return_frameworks(
                        app.descriptor,
                        self.engine.get_env(),
                    )),
                len(frameworks),
            )
        finally:
            # In case any future tests need to make use of the minimum
            # version requirements in the frameworks, we'll put them
            # back to what they were before.
            for fw in frameworks:
                if previous_mins[fw["name"]]:
                    fw["minimum_version"] = previous_mins[fw["name"]]
                else:
                    del fw["minimum_version"]
    def test_minimum_version(self):
        """
        Tests the min required frameworks for an app
        """
        app = self.engine.apps["test_app"]
        previous_mins = dict()
        frameworks = app.descriptor.required_frameworks

        for fw in frameworks:
            previous_mins[fw["name"]] = fw.get("minimum_version")
            fw["minimum_version"] = "v999.999.999"

        try:
            # We should get an error here due to the too-high
            # minumum required version for the frameworks.
            self.assertRaises(
                TankError,
                validation.validate_and_return_frameworks,
                app.descriptor,
                self.engine.get_env(),
            )

            for fw in frameworks:
                fw["minimum_version"] = "v0.0.0"

            # We should get back a list of framework objects that
            # is the same length as the number of required frameworks
            # we have.
            self.assertEqual(
                len(validation.validate_and_return_frameworks(
                    app.descriptor,
                    self.engine.get_env(),
                )),
                len(frameworks),
            )
        finally:
            # In case any future tests need to make use of the minimum
            # version requirements in the frameworks, we'll put them
            # back to what they were before.
            for fw in frameworks:
                if previous_mins[fw["name"]]:
                    fw["minimum_version"] = previous_mins[fw["name"]]
                else:
                    del fw["minimum_version"]