Ejemplo n.º 1
0
    def test_no_semantic_version(self):
        with pytest.raises(build_utils._VersionInvalidFormatException
                           ) as pytest_wrapped_e:
            build_utils._get_version(
                "foobar", existing_versions=build_utils._get_version_tags())

        assert pytest_wrapped_e.type is build_utils._VersionInvalidFormatException
    def test_with_too_small_patch(self):
        too_small_patch_version = "1.1.2"
        with pytest.raises(build_utils.VersionInvalidPatchNumber) as pytest_wrapped_e:
            build_utils._get_version(
                version=too_small_patch_version,
                existing_versions=build_utils._get_version_tags(),
            )
        assert pytest_wrapped_e.type is build_utils.VersionInvalidPatchNumber

        with pytest.raises(SystemExit) as pytest_wrapped_e:
            build_utils.get_sanitized_arguments(
                [f"--{build_utils.FLAG_VERSION}={too_small_patch_version}"]
            )

        assert pytest_wrapped_e.type == SystemExit
        assert pytest_wrapped_e.value.code == build_utils.EXIT_CODE_INVALID_VERSION
Ejemplo n.º 3
0
 def test_correct_semantic_minor_version(self):
     valid_version = build_utils._get_version(
         valid_minor_version,
         existing_versions=build_utils._get_version_tags())
     assert isinstance(valid_version, build_utils._Version)
     version_split = valid_minor_version.split(".")
     assert (valid_version.major == int(version_split[0])
             and valid_version.minor == int(version_split[1])
             and valid_version.patch == int(version_split[2])
             and not valid_version.suffix)