예제 #1
0
 def test_bad_length(self):
     a = ('1', '6.0.0', '2.el7ost', 1)
     b = ('0', '6.0.1', '2.el7ost')
     with pytest.raises(ValueError):
         labelCompare(a, b)
     with pytest.raises(ValueError):
         labelCompare(b, a)
예제 #2
0
 def test_basic(self):
     a = ('0', '6.0.0', '2.el7ost')
     b = ('0', '6.0.1', '2.el7ost')
     assert labelCompare(a, b) == -1
     assert labelCompare(a, a) == 0
     assert labelCompare(b, a) == 1
     assert labelCompare(b, b) == 0
예제 #3
0
 def test_bad_types(self):
     a = '1:6.0.0-2.el7ost'
     b = 1
     with pytest.raises(ValueError):
         labelCompare(a, b)
     with pytest.raises(ValueError):
         labelCompare(b, a)
예제 #4
0
 def test_eq_epoch(self):
     a = ('1', '6.0.0', '2.el7ost')
     b = ('1', '6.0.1', '2.el7ost')
     assert labelCompare(a, b) == -1
     assert labelCompare(a, a) == 0
     assert labelCompare(b, a) == 1
     assert labelCompare(b, b) == 0
예제 #5
0
 def test_vr_only(self):
     # no epoch => epoch = 0
     a = ('6.0.0', '2.el7ost')
     b = ('6.0.1', '2.el7ost')
     assert labelCompare(a, b) == -1
     assert labelCompare(a, a) == 0
     assert labelCompare(b, a) == 1
     assert labelCompare(b, b) == 0
예제 #6
0
 def test_neq_epoch(self):
     # a always wins.
     a = ('1', '6.0.0', '2.el7ost')
     b = ('0', '6.0.1', '2.el7ost')
     assert labelCompare(a, b) == 1
     assert labelCompare(a, a) == 0
     assert labelCompare(b, a) == -1
     assert labelCompare(b, b) == 0
예제 #7
0
    def find_highest_version(self, packages):
        """
        Get the highest version of rpms in a list

        This method should be replaced and we should
        use the yum python libraries

        Parameters:
        packages (dict): rpm key value pairs

        Returns:
        dict_of_rpms: dictionary of rpms w/ unique highest versions
        """
        dict_of_rpms = {}
        for key in packages:
            highest_version_tuple = packages[key][0]
            for item in packages[key]:
                if rpmvercmp.labelCompare(item, highest_version_tuple) == 1:
                    highest_version_tuple = item

            highest_version = highest_version_tuple[0]
            if len(highest_version_tuple) >= 2:
                highest_release = highest_version_tuple[1]
                highest_full_version = "{}-{}".format(highest_version,
                                                      highest_release)
            else:
                highest_full_version = "{}".format(highest_version)
            dict_of_rpms[key] = [highest_version, highest_full_version]
        return dict_of_rpms
예제 #8
0
    def test_zero_epoch(self):
        # 0 and no epoch are the same
        a = ('0', '6.0.0', '2.el7ost')
        b = ('6.0.1', '2.el7ost')
        assert labelCompare(a, b) == -1
        assert labelCompare(a, a) == 0
        assert labelCompare(b, a) == 1
        assert labelCompare(b, b) == 0

        # librpm seems to set '' to 0
        a = ('', '1.0', '1')
        b = ('1.0', '1')
        c = (0, '1.0', '1')
        d = ('0', '1.0', '1')
        assert labelCompare(a, b) == 0
        assert labelCompare(a, c) == 0
        assert labelCompare(a, d) == 0
        assert labelCompare(b, c) == 0
        assert labelCompare(b, d) == 0
        assert labelCompare(c, d) == 0
예제 #9
0
    def test_weird_versions(self):
        a = ('0', 'a', '1')
        b = ('0', '1', '1')
        assert labelCompare(a, b) == -1
        assert labelCompare(b, a) == 1

        a = ('0', '1.01.001', '1')
        b = ('0', '1.1.1', '1')
        assert labelCompare(a, b) == 0

        a = ('0', '~1', '1')
        b = ('0', '1', '1')
        assert labelCompare(a, b) == -1
        assert labelCompare(b, a) == 1

        a = ('0', '1~1', '1')
        b = ('0', '1', '1')
        assert labelCompare(a, b) == -1
        assert labelCompare(b, a) == 1
예제 #10
0
 def test_bad_epoch(self):
     a = ('abcde', '1.0', '1')
     b = ('1.0', '1')
     with pytest.raises(ValueError):
         labelCompare(a, b)