def test_pluck_metadata(): assert snap_store._pluck_metadata([ { "revision": 1, "version": "63.0b1-1", "current_channels": [], "some_other": "field" }, { "revision": 2, "version": "63.0b2-1", "current_channels": [] }, { "revision": 3, "version": "62.0-1", "current_channels": ["release", "candidate"] }, { "revision": 4, "version": "63.0b3-1", "current_channels": ["beta", "edge"] }, { "revision": 5, "version": "60.2.1esr-1", "current_channels": ["esr/stable", "esr/candidate", "esr/beta", "esr/edge"] }, ]) == { 1: { "version": GeckoSnapVersion.parse("63.0b1-1"), "current_channels": [] }, 2: { "version": GeckoSnapVersion.parse("63.0b2-1"), "current_channels": [] }, 3: { "version": GeckoSnapVersion.parse("62.0-1"), "current_channels": ["release", "candidate"] }, 4: { "version": GeckoSnapVersion.parse("63.0b3-1"), "current_channels": ["beta", "edge"] }, 5: { "version": GeckoSnapVersion.parse("60.2.1esr-1"), "current_channels": ["esr/stable", "esr/candidate", "esr/beta", "esr/edge"] }, }
def _pluck_metadata(snap_revisions): return { revision['revision']: { 'version': GeckoSnapVersion.parse(revision['version']), 'current_channels': revision.get('current_channels', []), } for revision in snap_revisions }
def _pluck_metadata(snap_revisions): return { revision["revision"]: { "version": GeckoSnapVersion.parse(revision["version"]), "current_channels": revision.get("current_channels", []) } for revision in snap_revisions }
def test_filter_versions_that_are_not_the_same_type(channel, expected): assert snap_store._filter_versions_that_are_not_the_same_type({ 1: { 'version': GeckoSnapVersion.parse('63.0b1-1'), }, 2: { 'version': GeckoSnapVersion.parse('63.0b2-1'), }, 3: { 'version': GeckoSnapVersion.parse('62.0-1'), }, 4: { 'version': GeckoSnapVersion.parse('63.0b3-1'), }, 5: { 'version': GeckoSnapVersion.parse('60.2.1esr-1'), }, }, channel) == expected
def test_pluck_metadata(): assert snap_store._pluck_metadata([{ 'revision': 1, 'version': '63.0b1-1', 'current_channels': [], 'some_other': 'field', }, { 'revision': 2, 'version': '63.0b2-1', 'current_channels': [], }, { 'revision': 3, 'version': '62.0-1', 'current_channels': ['release', 'candidate'], }, { 'revision': 4, 'version': '63.0b3-1', 'current_channels': ['beta', 'edge'], }, { 'revision': 5, 'version': '60.2.1esr-1', 'current_channels': ['esr/stable', 'esr/candidate', 'esr/beta', 'esr/edge'], }]) == { 1: { 'version': GeckoSnapVersion.parse('63.0b1-1'), 'current_channels': [], }, 2: { 'version': GeckoSnapVersion.parse('63.0b2-1'), 'current_channels': [], }, 3: { 'version': GeckoSnapVersion.parse('62.0-1'), 'current_channels': ['release', 'candidate'], }, 4: { 'version': GeckoSnapVersion.parse('63.0b3-1'), 'current_channels': ['beta', 'edge'], }, 5: { 'version': GeckoSnapVersion.parse('60.2.1esr-1'), 'current_channels': ['esr/stable', 'esr/candidate', 'esr/beta', 'esr/edge'], }, }
def test_filter_versions_that_are_not_the_same_type(channel, expected): assert (snap_store._filter_versions_that_are_not_the_same_type( { 1: { "version": GeckoSnapVersion.parse("63.0b1-1") }, 2: { "version": GeckoSnapVersion.parse("63.0b2-1") }, 3: { "version": GeckoSnapVersion.parse("62.0-1") }, 4: { "version": GeckoSnapVersion.parse("63.0b3-1") }, 5: { "version": GeckoSnapVersion.parse("60.2.1esr-1") }, }, channel, ) == expected)
def test_gecko_snap_version_implements_its_own_string(): assert str(GeckoSnapVersion.parse('63.0b7-1')) == '63.0b7-1'
def test_gecko_snap_version_bails_on_wrong_version(version_string): with pytest.raises(PatternNotMatchedError): GeckoSnapVersion.parse(version_string)
def test_gecko_snap_version(version_string): GeckoSnapVersion.parse(version_string)
}, 4: { 'version': GeckoSnapVersion.parse('63.0b3-1'), 'current_channels': ['beta', 'edge'], }, 5: { 'version': GeckoSnapVersion.parse('60.2.1esr-1'), 'current_channels': ['esr/stable', 'esr/candidate', 'esr/beta', 'esr/edge'], }, } @pytest.mark.parametrize('channel, expected', (( 'beta', { 1: { 'version': GeckoSnapVersion.parse('63.0b1-1'), }, 2: { 'version': GeckoSnapVersion.parse('63.0b2-1'), }, 3: { 'version': GeckoSnapVersion.parse('62.0-1'), }, 4: { 'version': GeckoSnapVersion.parse('63.0b3-1'), }, } ), ( 'stable', { 3: { 'version': GeckoSnapVersion.parse('62.0-1'),
"version": GeckoSnapVersion.parse("60.2.1esr-1"), "current_channels": ["esr/stable", "esr/candidate", "esr/beta", "esr/edge"] }, } @pytest.mark.parametrize( "channel, expected", ( ( "beta", { 1: { "version": GeckoSnapVersion.parse("63.0b1-1") }, 2: { "version": GeckoSnapVersion.parse("63.0b2-1") }, 3: { "version": GeckoSnapVersion.parse("62.0-1") }, 4: { "version": GeckoSnapVersion.parse("63.0b3-1") }, }, ), ("stable", { 3: { "version": GeckoSnapVersion.parse("62.0-1")