| |
@@ -300,6 +300,8 @@
|
| |
assert res == 'Fedora-Atomic-24-20161004.1'
|
| |
res = fedfind.helpers.find_cid('FedoraRespin-24-20161206.0')
|
| |
assert res == 'FedoraRespin-24-20161206.0'
|
| |
+ res = fedfind.helpers.find_cid('FedoraRespin-24-updates-20161206.0')
|
| |
+ assert res == 'FedoraRespin-24-updates-20161206.0'
|
| |
# a few 'close but no cigars' just for safety...
|
| |
res = fedfind.helpers.find_cid('https://foo.com/compose/Fedora-24-20160314.t.u/compose')
|
| |
assert res == ''
|
| |
@@ -308,33 +310,94 @@
|
| |
res = fedfind.helpers.find_cid('https://foo.com/compose/Fedora/24-20160314.n.0/compose')
|
| |
assert res == ''
|
| |
|
| |
- def test_parse_cid(self):
|
| |
+ @pytest.mark.parametrize(
|
| |
+ ("cid", "short", "version", "version_type", "base_short", "base_version", "base_type",
|
| |
+ "variant", "date", "compose_type", "respin"),
|
| |
+ [
|
| |
+ ('Fedora-24-20160314.n.0', 'Fedora', '24', 'ga', '', '', '', '', '20160314', 'nightly',
|
| |
+ 0),
|
| |
+ ('Fedora-24-20160314.0', 'Fedora', '24', 'ga', '', '', '', '', '20160314',
|
| |
+ 'production', 0),
|
| |
+ ('Fedora-24-20160314.t.0', 'Fedora', '24', 'ga', '', '', '', '', '20160314', 'test', 0),
|
| |
+ ('Fedora-Rawhide-20160314.n.1', 'Fedora', 'Rawhide', 'ga', '', '', '', '', '20160314',
|
| |
+ 'nightly', 1),
|
| |
+ ('Fedora-Atomic-24-20160628.0', 'Fedora-Atomic', '24', 'ga', '', '', '', '',
|
| |
+ '20160628', 'production', 0),
|
| |
+ ('Fedora-20-19700101.0', 'Fedora', '20', 'ga', '', '', '', '', '19700101',
|
| |
+ 'production', 0),
|
| |
+ ('FedoraRespin-24-updates-20161206.0', 'FedoraRespin', '24', 'updates', '', '', '', '',
|
| |
+ '20161206', 'production', 0),
|
| |
+ # older fake Respin CID
|
| |
+ ('FedoraRespin-24-20161206.0', 'FedoraRespin', '24', 'ga', '', '', '', '', '20161206',
|
| |
+ 'production', 0),
|
| |
+ # taken from productmd test_composeinfo
|
| |
+ ('Fedora-22-20160622.0', 'Fedora', '22', 'ga', '', '', '', '', '20160622', 'production',
|
| |
+ 0),
|
| |
+ # FIXME: 'ci' is a valid compose type now but get_date_type_respin doesn't handle it
|
| |
+ # 'Fedora-22-20160622.ci.0'
|
| |
+ ('Fedora-22-updates-20160622.0', 'Fedora', '22', 'updates', '', '', '', '', '20160622',
|
| |
+ 'production', 0),
|
| |
+ ('Fedora-22-updates-20160622.n.0', 'Fedora', '22', 'updates', '', '', '', '',
|
| |
+ '20160622', 'nightly', 0),
|
| |
+ ('Fedora-22-BASE-3-20160622.0', 'Fedora', '22', 'ga', 'BASE', '3', 'ga', '', '20160622',
|
| |
+ 'production', 0),
|
| |
+ ('Fedora-22-BASE-3-20160622.n.0', 'Fedora', '22', 'ga', 'BASE', '3', 'ga', '',
|
| |
+ '20160622', 'nightly', 0),
|
| |
+ ('Fedora-22-updates-BASE-3-20160622.0', 'Fedora', '22', 'updates', 'BASE', '3', 'ga',
|
| |
+ '', '20160622', 'production', 0),
|
| |
+ ('Fedora-22-updates-BASE-3-20160622.n.0', 'Fedora', '22', 'updates', 'BASE', '3', 'ga',
|
| |
+ '', '20160622', 'nightly', 0),
|
| |
+ ('Fedora-22-BASE-3-updates-20160622.0', 'Fedora', '22', 'ga', 'BASE', '3', 'updates',
|
| |
+ '', '20160622', 'production', 0),
|
| |
+ ('Fedora-22-BASE-3-updates-20160622.n.0', 'Fedora', '22', 'ga', 'BASE', '3', 'updates',
|
| |
+ '', '20160622', 'nightly', 0),
|
| |
+ ('Fedora-22-updates-BASE-3-updates-20160622.0', 'Fedora', '22', 'updates', 'BASE', '3',
|
| |
+ 'updates', '', '20160622', 'production', 0),
|
| |
+ ('Fedora-22-updates-BASE-3-updates-20160622.n.0', 'Fedora', '22', 'updates', 'BASE',
|
| |
+ '3', 'updates', '', '20160622', 'nightly', 0),
|
| |
+ # Rawhide complex
|
| |
+ ('Fedora-Rawhide-updates-RHEL-6.3.4-20160513.t.1', 'Fedora', 'Rawhide', 'updates',
|
| |
+ 'RHEL', '6.3.4', 'ga', '', '20160513', 'test', 1),
|
| |
+ # I think this is how a RHEL 5 one looks?
|
| |
+ ('Fedora-5-updates-Server-20160523.2', 'Fedora', '5', 'updates', '', '', '', 'Server',
|
| |
+ '20160523', 'production', 2),
|
| |
+ ('Fedora-5-updates-Client-20160523.2', 'Fedora', '5', 'updates', '', '', '', 'Client',
|
| |
+ '20160523', 'production', 2),
|
| |
+ ]
|
| |
+ )
|
| |
+ def test_parse_cid(self, cid, short, version, version_type, base_short, base_version,
|
| |
+ base_type, variant, date, compose_type, respin):
|
| |
"""Check parse_cid works correctly, with various known compose
|
| |
ID forms.
|
| |
"""
|
| |
+ assert fedfind.helpers.parse_cid(cid, dic=True) == {
|
| |
+ 'short': short,
|
| |
+ 'version': version,
|
| |
+ 'version_type': version_type,
|
| |
+ 'base_short': base_short,
|
| |
+ 'base_version': base_version,
|
| |
+ 'base_type': base_type,
|
| |
+ 'variant': variant,
|
| |
+ 'date': date,
|
| |
+ 'compose_type': compose_type,
|
| |
+ 'respin': respin
|
| |
+ }
|
| |
+
|
| |
+ def test_parse_cid_tuple(self):
|
| |
+ """Check the two older tuple formats for parse_cid work as
|
| |
+ expected.
|
| |
+ """
|
| |
res = fedfind.helpers.parse_cid('Fedora-24-20160314.n.0')
|
| |
assert res == ('24', '20160314', 'nightly', 0)
|
| |
res = fedfind.helpers.parse_cid('Fedora-24-20160314.n.0', dist=True)
|
| |
assert res == ('Fedora', '24', '20160314', 'nightly', 0)
|
| |
- res = fedfind.helpers.parse_cid('Fedora-24-20160314.0')
|
| |
- assert res == ('24', '20160314', 'production', 0)
|
| |
- res = fedfind.helpers.parse_cid('Fedora-24-20160314.t.0')
|
| |
- assert res == ('24', '20160314', 'test', 0)
|
| |
- res = fedfind.helpers.parse_cid('Fedora-Rawhide-20160314.n.1')
|
| |
- assert res == ('rawhide', '20160314', 'nightly', 1)
|
| |
- # Two-week Atomic uses a different product name
|
| |
- res = fedfind.helpers.parse_cid('Fedora-Atomic-24-20160628.0')
|
| |
- assert res == ('24', '20160628', 'production', 0)
|
| |
res = fedfind.helpers.parse_cid('Fedora-Atomic-24-20160628.0', dist=True)
|
| |
assert res == ('Fedora-Atomic', '24', '20160628', 'production', 0)
|
| |
- # should raise ValueError for non-Pungi 4-ish CID
|
| |
+
|
| |
+ def test_parse_cid_error(self):
|
| |
+ """Check parse_cid raises ValueError for non-Pungi 4-ish CID."""
|
| |
with pytest.raises(ValueError):
|
| |
res = fedfind.helpers.parse_cid('23-20160530')
|
| |
- # should handle our own fake compose IDs, though
|
| |
- res = fedfind.helpers.parse_cid('Fedora-20-19700101.0', dist=True)
|
| |
- assert res == ('Fedora', '20', '19700101', 'production', 0)
|
| |
- res = fedfind.helpers.parse_cid('FedoraRespin-24-20161206.0', dist=True)
|
| |
- assert res == ('FedoraRespin', '24', '20161206', 'production', 0)
|
| |
|
| |
@mock.patch('fedfind.helpers.download_json', return_value=PDC_JSON_REAL, autospec=True)
|
| |
def test_cid_from_label(self, fakejson):
|
| |
What we had was relying a lot on things that happen to be true
of Fedora compose IDs, but aren't part of the rules for compose
IDs in general at all. This should come a lot closer to being
a 'generic' compose ID parser that can handle almost anything
that conforms to the rules productmd enforces. It should handle
layered products, type suffixes, and RHEL-ish versions.
Signed-off-by: Adam Williamson awilliam@redhat.com