예제 #1
0
 def test_to_dev(self):
     self.assertEqual(
         version.SemanticVersion(1, 2, 3, dev_count=1, githash='foo'),
         version.SemanticVersion(1, 2, 3).to_dev(1, 'foo'))
     self.assertEqual(
         version.SemanticVersion(1, 2, 3, dev_count=1, githash='foo'),
         version.SemanticVersion(1, 2, 3, 'rc', 1).to_dev(1, 'foo'))
예제 #2
0
 def test_to_dev(self):
     self.assertEqual(
         version.SemanticVersion(1, 2, 3, dev_count=1),
         version.SemanticVersion(1, 2, 3).to_dev(1))
     self.assertEqual(
         version.SemanticVersion(1, 2, 3, 'rc', 1, dev_count=1),
         version.SemanticVersion(1, 2, 3, 'rc', 1).to_dev(1))
예제 #3
0
 def test_increment_release(self):
     # The next patch version of a release version requires a change to the
     # patch level.
     semver = version.SemanticVersion(1, 2, 5)
     self.assertEqual(version.SemanticVersion(1, 2, 6), semver.increment())
     self.assertEqual(version.SemanticVersion(1, 3, 0),
                      semver.increment(minor=True))
     self.assertEqual(version.SemanticVersion(2, 0, 0),
                      semver.increment(major=True))
예제 #4
0
    def test_from_pip_string_v_version(self):
        parsed = from_pip_string('v1.2.3')
        expected = version.SemanticVersion(1, 2, 3)
        self.expectThat(expected, matchers.Equals(parsed))

        expected = version.SemanticVersion(1, 2, 3, 'a', 5, dev_count=6)
        parsed = from_pip_string('V1.2.3.0a4.post6')
        self.expectThat(expected, matchers.Equals(parsed))

        self.expectThat(lambda: from_pip_string('x1.2.3'),
                        matchers.raises(ValueError))
예제 #5
0
 def test_increment_nonrelease(self):
     # The next patch version of a non-release version is another
     # non-release version as the next release doesn't need to be
     # incremented.
     semver = version.SemanticVersion(1, 2, 4, 'b', 1)
     self.assertEqual(version.SemanticVersion(1, 2, 4, 'b', 2),
                      semver.increment())
     # Major and minor increments however need to bump things.
     self.assertEqual(version.SemanticVersion(1, 3, 0),
                      semver.increment(minor=True))
     self.assertEqual(version.SemanticVersion(2, 0, 0),
                      semver.increment(major=True))
예제 #6
0
 def test_from_pip_string_legacy_postN(self):
     # When pbr trunk was incompatible with PEP-440, a stable release was
     # made that used postN versions to represent developer builds. As
     # we expect only to be parsing versions of our own, we map those
     # into dev builds of the next version.
     expected = version.SemanticVersion(1, 2, 4, dev_count=5)
     parsed = from_pip_string('1.2.3.post5')
     self.expectThat(expected, matchers.Equals(parsed))
     expected = version.SemanticVersion(1, 2, 3, 'a', 5, dev_count=6)
     parsed = from_pip_string('1.2.3.0a4.post6')
     self.expectThat(expected, matchers.Equals(parsed))
     # We can't define a mapping for .postN.devM, so it should raise.
     self.expectThat(lambda: from_pip_string('1.2.3.post5.dev6'),
                     matchers.raises(ValueError))
예제 #7
0
 def test_from_pip_string_dev_missing_patch_version(self):
     expected = version.SemanticVersion(2014,
                                        2,
                                        dev_count=21,
                                        githash='c4c8d0b')
     parsed = from_pip_string('2014.2.dev21.gc4c8d0b')
     self.assertEqual(expected, parsed)
예제 #8
0
 def test_from_pip_string_legacy_non_440_beta(self):
     expected = version.SemanticVersion(2014,
                                        2,
                                        prerelease_type='b',
                                        prerelease=2)
     parsed = from_pip_string('2014.2.b2')
     self.assertEqual(expected, parsed)
예제 #9
0
 def test_from_pip_string_legacy_dev(self):
     expected = version.SemanticVersion(0,
                                        10,
                                        1,
                                        dev_count=3,
                                        githash='83bef74')
     parsed = from_pip_string('0.10.1.3.g83bef74')
     self.assertEqual(expected, parsed)
예제 #10
0
 def test_from_pip_string_legacy_no_0_prerelease_2(self):
     expected = version.SemanticVersion(2,
                                        0,
                                        0,
                                        prerelease_type='rc',
                                        prerelease=1)
     parsed = from_pip_string('2.0.0.rc1')
     self.assertEqual(expected, parsed)
예제 #11
0
 def test_from_pip_string_legacy_short_nonzero_lead_in(self):
     expected = version.SemanticVersion(0,
                                        1,
                                        0,
                                        prerelease_type='a',
                                        prerelease=2)
     parsed = from_pip_string('0.1a2')
     self.assertEqual(expected, parsed)
예제 #12
0
 def test_alpha_dev_version(self):
     semver = version.SemanticVersion(1, 2, 4, 'a', 1, 12)
     self.assertEqual((1, 2, 4, 'alphadev', 12), semver.version_tuple())
     self.assertEqual("1.2.4", semver.brief_string())
     self.assertEqual("1.2.4~a1.dev12", semver.debian_string())
     self.assertEqual("1.2.4.0a1.dev12", semver.release_string())
     self.assertEqual("1.2.3.a1.dev12", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.4.0a1.dev12"))
예제 #13
0
 def test_client_use_new_attach_v1_cinderclient(self,
                                                mock_semantic_version):
     self._init_fake_cinderclient('iscsi')
     mock_semantic_version.return_value = pbr_version.SemanticVersion(
         major=1, minor=0)
     self.client.volumes_client.version_info.semantic_version
     brick_client = client.Client(self.client.volumes_client)
     self.assertTrue(brick_client._use_legacy_attach)
예제 #14
0
 def test_final_version(self):
     semver = version.SemanticVersion(1, 2, 3)
     self.assertEqual((1, 2, 3, 'final', 0), semver.version_tuple())
     self.assertEqual("1.2.3", semver.brief_string())
     self.assertEqual("1.2.3", semver.debian_string())
     self.assertEqual("1.2.3", semver.release_string())
     self.assertEqual("1.2.3", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.3"))
예제 #15
0
 def test_dev_no_git_version(self):
     semver = version.SemanticVersion(1, 2, 4, dev_count=5)
     self.assertEqual((1, 2, 4, 'dev', 4), semver.version_tuple())
     self.assertEqual("1.2.4", semver.brief_string())
     self.assertEqual("1.2.4~dev5", semver.debian_string())
     self.assertEqual("1.2.4.dev5", semver.release_string())
     self.assertEqual("1.2.3.dev5", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.4.dev5"))
예제 #16
0
 def test_from_pip_string_legacy_alpha(self):
     expected = version.SemanticVersion(1,
                                        2,
                                        0,
                                        prerelease_type='rc',
                                        prerelease=1)
     parsed = from_pip_string('1.2.0rc1')
     self.assertEqual(expected, parsed)
예제 #17
0
 def test_beta_version(self):
     semver = version.SemanticVersion(1, 2, 4, 'b', 1)
     self.assertEqual((1, 2, 4, 'beta', 1), semver.version_tuple())
     self.assertEqual("1.2.4", semver.brief_string())
     self.assertEqual("1.2.4~b1", semver.debian_string())
     self.assertEqual("1.2.4.0b1", semver.release_string())
     self.assertEqual("1.2.3.b1", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.4.0b1"))
예제 #18
0
 def test_rc_version(self):
     semver = version.SemanticVersion(1, 2, 4, 'rc', 1)
     self.assertEqual((1, 2, 4, 'candidate', 1), semver.version_tuple())
     self.assertEqual("1.2.4", semver.brief_string())
     self.assertEqual("1.2.4~rc1", semver.debian_string())
     self.assertEqual("1.2.4.0rc1", semver.release_string())
     self.assertEqual("1.2.3.rc1", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.4.0rc1"))
예제 #19
0
 def test_alpha_default_version(self):
     semver = version.SemanticVersion(1, 2, 4, 'a')
     self.assertEqual((1, 2, 4, 'alpha', 0), semver.version_tuple())
     self.assertEqual("1.2.4", semver.brief_string())
     self.assertEqual("1.2.4~a0", semver.debian_string())
     self.assertEqual("1.2.4.0a0", semver.release_string())
     self.assertEqual("1.2.3.a0", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.4.0a0"))
예제 #20
0
 def test_alpha_major_zero_version(self):
     semver = version.SemanticVersion(1, 0, 0, 'a', 1)
     self.assertEqual((1, 0, 0, 'alpha', 1), semver.version_tuple())
     self.assertEqual("1.0.0", semver.brief_string())
     self.assertEqual("1.0.0~a1", semver.debian_string())
     self.assertEqual("1.0.0.0a1", semver.release_string())
     self.assertEqual("0.9999.9999.a1", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.0.0.0a1"))
예제 #21
0
 def test_dev_zero_version(self):
     semver = version.SemanticVersion(1, 2, 0, dev_count=5)
     self.assertEqual((1, 2, 0, 'dev', 4), semver.version_tuple())
     self.assertEqual("1.2.0", semver.brief_string())
     self.assertEqual("1.2.0~dev5", semver.debian_string())
     self.assertEqual("1.2.0.dev5", semver.release_string())
     self.assertEqual("1.1.9999.dev5", semver.rpm_string())
     self.assertEqual(semver, from_pip_string("1.2.0.dev5"))
예제 #22
0
 def test_from_pip_string_legacy_nonzero_lead_in(self):
     # reported in bug 1361251
     expected = version.SemanticVersion(0,
                                        0,
                                        1,
                                        prerelease_type='a',
                                        prerelease=2)
     parsed = from_pip_string('0.0.1a2')
     self.assertEqual(expected, parsed)
예제 #23
0
 def test_from_pip_string_legacy_short_dev(self):
     # If the last tag is missing, or if the last tag has less than 3
     # components, we need to 0 extend on parsing.
     expected = version.SemanticVersion(0,
                                        0,
                                        0,
                                        dev_count=1,
                                        githash='83bef74')
     parsed = from_pip_string('0.g83bef74')
     self.assertEqual(expected, parsed)
예제 #24
0
    def test_client_use_new_attach_v2_cinderclient_3_0(self,
                                                       mock_semantic_version):
        self._init_fake_cinderclient('iscsi')
        mock_semantic_version.return_value = pbr_version.SemanticVersion(
            major=2, minor=0)
        self.client.volumes_client.version_info.semantic_version
        current_api_version = api_versions.APIVersion("3.0")
        self.client.volumes_client.api_version = current_api_version
        brick_client = client.Client(self.client.volumes_client)

        self.assertTrue(brick_client._use_legacy_attach)
예제 #25
0
파일: builddoc.py 프로젝트: nealmcb/pbr
    def run(self):
        option_dict = self.distribution.get_option_dict('pbr')
        if git._git_is_installed():
            git.write_git_changelog(option_dict=option_dict)
            git.generate_authors(option_dict=option_dict)
        tree_index = options.get_boolean_option(option_dict,
                                                'autodoc_tree_index_modules',
                                                'AUTODOC_TREE_INDEX_MODULES')
        auto_index = options.get_boolean_option(option_dict,
                                                'autodoc_index_modules',
                                                'AUTODOC_INDEX_MODULES')
        if not os.getenv('SPHINX_DEBUG'):
            # NOTE(afazekas): These options can be used together,
            # but they do a very similar thing in a different way
            if tree_index:
                self._sphinx_tree()
            if auto_index:
                self.generate_autoindex(
                    set(
                        option_dict.get("autodoc_exclude_modules",
                                        [None, ""])[1].split()))

        self.finalize_options()

        is_multibuilder_sphinx = version.SemanticVersion.from_pip_string(
            sphinx.__version__) >= version.SemanticVersion(1, 6)

        # TODO(stephenfin): Remove support for Sphinx < 1.6 in 4.0
        if not is_multibuilder_sphinx:
            log.warning('[pbr] Support for Sphinx < 1.6 will be dropped in '
                        'pbr 4.0. Upgrade to Sphinx 1.6+')

        # TODO(stephenfin): Remove this at the next MAJOR version bump
        if self.builders != ['html']:
            log.warning("[pbr] Sphinx 1.6 added native support for "
                        "specifying multiple builders in the "
                        "'[sphinx_build] builder' configuration option, "
                        "found in 'setup.cfg'. As a result, the "
                        "'[sphinx_build] builders' option has been "
                        "deprecated and will be removed in pbr 4.0. Migrate "
                        "to the 'builder' configuration option.")
            if is_multibuilder_sphinx:
                self.builder = self.builders

        if is_multibuilder_sphinx:
            # Sphinx >= 1.6
            return setup_command.BuildDoc.run(self)

        # Sphinx < 1.6
        for builder in self.builder:
            self.builder = builder
            self.finalize_options()
            self._sphinx_run()
    def __init__(self, volumes_client=None):
        self.volumes_client = volumes_client

        # Test to see if we have a version of the cinderclient
        # that can do the new volume attach/detach API
        version_want = pbr_version.SemanticVersion(major=2)
        current_version = cinderclient.version_info.semantic_version()
        if (self.volumes_client and current_version >= version_want):
            # We have a recent enough client to test the microversion we need.
            required_version = api_versions.APIVersion("3.44")
            if self.volumes_client.api_version.matches(required_version):
                # we can use the new attach/detach API
                self._use_legacy_attach = False
예제 #27
0
 def test_ordering(self):
     base = version.SemanticVersion(1, 2, 3)
     major = version.SemanticVersion(2, 2, 3)
     minor = version.SemanticVersion(1, 3, 3)
     patch = version.SemanticVersion(1, 2, 4)
     pre_alpha = version.SemanticVersion(1, 2, 3, 'a', 4)
     pre_beta = version.SemanticVersion(1, 2, 3, 'b', 3)
     pre_rc = version.SemanticVersion(1, 2, 3, 'rc', 2)
     pre_serial = version.SemanticVersion(1, 2, 3, 'a', 5)
     dev_base = version.SemanticVersion(1, 2, 3, dev_count=6, githash='6')
     dev_count = version.SemanticVersion(1, 2, 3, dev_count=7, githash='6')
     githash = version.SemanticVersion(1, 2, 3, dev_count=6, githash='7')
     self.assertThat(base, matchers.LessThan(major))
     self.assertThat(major, matchers.GreaterThan(base))
     self.assertThat(base, matchers.LessThan(minor))
     self.assertThat(minor, matchers.GreaterThan(base))
     self.assertThat(base, matchers.LessThan(patch))
     self.assertThat(patch, matchers.GreaterThan(base))
     self.assertThat(pre_alpha, matchers.LessThan(base))
     self.assertThat(base, matchers.GreaterThan(pre_alpha))
     self.assertThat(pre_alpha, matchers.LessThan(pre_beta))
     self.assertThat(pre_beta, matchers.GreaterThan(pre_alpha))
     self.assertThat(pre_beta, matchers.LessThan(pre_rc))
     self.assertThat(pre_rc, matchers.GreaterThan(pre_beta))
     self.assertThat(pre_alpha, matchers.LessThan(pre_serial))
     self.assertThat(pre_serial, matchers.GreaterThan(pre_alpha))
     self.assertThat(pre_serial, matchers.LessThan(pre_beta))
     self.assertThat(pre_beta, matchers.GreaterThan(pre_serial))
     self.assertThat(dev_base, matchers.LessThan(base))
     self.assertThat(base, matchers.GreaterThan(dev_base))
     self.assertRaises(TypeError, operator.lt, pre_alpha, dev_base)
     self.assertRaises(TypeError, operator.lt, dev_base, pre_alpha)
     self.assertThat(dev_base, matchers.LessThan(dev_count))
     self.assertThat(dev_count, matchers.GreaterThan(dev_base))
     self.assertRaises(TypeError, operator.lt, dev_base, githash)
예제 #28
0
 def test_decrement_nonrelease_zero(self):
     # We set an arbitrary max version of 9999 when decrementing versions
     # - this is part of handling rpm support.
     semver = version.SemanticVersion(1, 0, 0)
     self.assertEqual(version.SemanticVersion(0, 9999, 9999),
                      semver.decrement())
예제 #29
0
 def test_decrement_nonrelease(self):
     # The prior version of any non-release is a release
     semver = version.SemanticVersion(1, 2, 4, 'b', 1)
     self.assertEqual(version.SemanticVersion(1, 2, 3), semver.decrement())
예제 #30
0
 def test_equality(self):
     base = version.SemanticVersion(1, 2, 3)
     base2 = version.SemanticVersion(1, 2, 3)
     major = version.SemanticVersion(2, 2, 3)
     minor = version.SemanticVersion(1, 3, 3)
     patch = version.SemanticVersion(1, 2, 4)
     pre_base = version.SemanticVersion(1, 2, 3, 'a', 4)
     pre_base2 = version.SemanticVersion(1, 2, 3, 'a', 4)
     pre_type = version.SemanticVersion(1, 2, 3, 'b', 4)
     pre_serial = version.SemanticVersion(1, 2, 3, 'a', 5)
     dev_base = version.SemanticVersion(1, 2, 3, dev_count=6, githash='6')
     dev_base2 = version.SemanticVersion(1, 2, 3, dev_count=6, githash='6')
     dev_count = version.SemanticVersion(1, 2, 3, dev_count=7, githash='6')
     githash = version.SemanticVersion(1, 2, 3, dev_count=6, githash='7')
     self.assertEqual(base, base2)
     self.assertNotEqual(base, major)
     self.assertNotEqual(base, minor)
     self.assertNotEqual(base, patch)
     self.assertNotEqual(base, pre_type)
     self.assertNotEqual(base, pre_serial)
     self.assertNotEqual(base, dev_count)
     self.assertNotEqual(base, githash)
     self.assertEqual(pre_base, pre_base2)
     self.assertNotEqual(pre_base, pre_type)
     self.assertNotEqual(pre_base, pre_serial)
     self.assertNotEqual(pre_base, dev_count)
     self.assertNotEqual(pre_base, githash)
     self.assertEqual(dev_base, dev_base2)
     self.assertNotEqual(dev_base, dev_count)
     self.assertNotEqual(dev_base, githash)
     simple = version.SemanticVersion(1)
     explicit_minor = version.SemanticVersion(1, 0)
     explicit_patch = version.SemanticVersion(1, 0, 0)
     self.assertEqual(simple, explicit_minor)
     self.assertEqual(simple, explicit_patch)
     self.assertEqual(explicit_minor, explicit_patch)