Example #1
0
    def __init__(self, reference):
        self._fields = {}
        repo, sep, ref = reference.partition("/")
        if len(sep) == 0:
            ref = repo
            self.repo = None
        elif len(repo) == 0:
            self.repo = None
        else:
            self.repo = repo

        if self.key_regexp.match(ref):
            m = self.key_regexp.match(ref)
            self._fields["prefix"] = m.group(1)  # None if empty
            self._fields["arch"] = m.group(2)
            self._fields["name"] = m.group(3)
            self._fields["version"] = Version(m.group(4))
            self._fields["hash"] = m.group(5)
        elif self.dir_ref_regexp.match(ref):
            m = self.dir_ref_regexp.match(ref)
            self._fields["prefix"] = None
            self._fields["name"] = m.group(1)
            self._fields["version"] = Version(m.group(2))
            self._fields["arch"] = m.group(3)
            self._fields["hash"] = None
        else:
            raise ValueError('Incorrect package reference "%s"' % reference)
Example #2
0
 def test_constructor_from_direct_ref_with_repo(self):
     r = PackageRef("jessie_unstable/aptly_2.2.0~rc5_amd64")
     assert r.prefix is None
     assert r.arch == "amd64"
     assert r.name == "aptly"
     assert r.version == Version("2.2.0~rc5")
     assert r.hash is None
     assert r.repo == "jessie_unstable"
Example #3
0
 def test_constructor_from_aptly_key(self):
     r = PackageRef("Pamd64 aptly 2.2.0~rc5 f2b7dc2061b9d95c")
     assert r.prefix is None
     assert r.arch == "amd64"
     assert r.name == "aptly"
     assert r.version == Version("2.2.0~rc5")
     assert r.hash == "f2b7dc2061b9d95c"
     assert r.repo is None
Example #4
0
 def test_upsream_ver_cmp_empty_vs_decimal_part(self):
     A = Version("1.2.")
     B = Version("1.2.0")
     assert A == B
Example #5
0
 def test_version_constructor_non_ascii(self):
     with pytest.raises(ValueError):
         v = Version("1.0-ю3")
Example #6
0
 def test_upsream_ver_cmp_empty_vs_non_decimal_part(self):
     A = Version("1.2")
     B = Version("1.2.1")
     assert A < B and B > A
Example #7
0
 def test_upsream_ver_cmp_alphabet_order(self):
     A = Version("1.2.ananas")
     B = Version("1.2.apple")
     assert A < B and B > A
Example #8
0
 def test_revision_cmp_tilde_erlier_then_anything(self):
     A = Version("1.2-1~1")
     B = Version("1.2-1a")
     assert A < B and B > A
Example #9
0
 def test_revision_cmp_empty_vs_something(self):
     A = Version("1.2")
     B = Version("1.2-1")
     assert A < B and B > A
Example #10
0
 def test_revision_cmp_numeric_order(self):
     A = Version("1.1-1")
     B = Version("1.1-2")
     assert A < B and B > A
Example #11
0
 def test_epoch_cmp_nonzero(self):
     A = Version("1:1.0")
     B = Version("2:1.0")
     assert A < B and B > A
Example #12
0
 def test_version_constructor_err_on_upstream_version_starts_with_non_decimal(
         self):
     with pytest.raises(ValueError):
         v = Version("a1.0-1")
Example #13
0
 def test_version_constructor_err_on_empty_epoch(self):
     with pytest.raises(ValueError):
         v = Version(":1.1")
Example #14
0
 def test_version_constructor_err_on_empty_revision(self):
     with pytest.raises(ValueError):
         v = Version("1.1-")
Example #15
0
 def test_version_constructor_err_on_empty_upstream_version(self):
     with pytest.raises(ValueError):
         v = Version("1:-1")
Example #16
0
 def test_version_constructor_err_on_non_decimal_epoch(self):
     with pytest.raises(ValueError):
         v = Version("1a:1.0")
Example #17
0
 def test_upsream_ver_cmp_tilde_erlier_then_empty(self):
     A = Version("1.2~1")
     B = Version("1.2")
     assert A < B and B > A
Example #18
0
 def test_upsream_ver_cmp_tilde_erlier_then_anything(self):
     A = Version("1.2~1")
     B = Version("1.2-1")
     assert A < B and B > A
Example #19
0
 def test_epoch_cmp_empty_with_nonzero(self):
     A = Version("1.0")
     B = Version("1:1.0")
     assert A < B and B > A
Example #20
0
 def test_revision_cmp_alphabet_order(self):
     A = Version("1.2-1a")
     B = Version("1.2-1b")
     assert A < B and B > A
Example #21
0
 def test_revision_cmp_tilde_erlier_then_empty(self):
     A = Version("1.2-1~a")
     B = Version("1.2-1")
     assert A < B and B > A
Example #22
0
 def test_epoch_cmp_empty_with_zero(self):
     A = Version("1.0")
     B = Version("0:1.0")
     assert A == B
Example #23
0
 def test_version_constructor_err_on_negative_epoch(self):
     with pytest.raises(ValueError):
         v = Version("-1:1.0")
Example #24
0
 def test_upsream_ver_cmp_numeric_order(self):
     A = Version("1.2")
     B = Version("1.10")
     assert A < B and B > A
Example #25
0
 def test_revision_cmp_empty_vs_zero(self):
     A = Version("1.2")
     B = Version("1.2-0")
     assert A == B