test_buglist_creator.py (5018B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 # -*- coding: utf-8 -*- 6 # This Source Code Form is subject to the terms of the Mozilla Public 7 # License, v. 2.0. If a copy of the MPL was not distributed with this 8 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 10 from pathlib import Path 11 12 import mozunit 13 import pytest 14 from mozfile import json 15 from mozilla_version.gecko import GeckoVersion 16 17 from mozrelease.buglist_creator import ( 18 create_bugs_url, 19 get_bugs_in_changeset, 20 get_previous_tag_version, 21 is_backout_bug, 22 is_excluded_change, 23 parse_tag_version, 24 tag_version, 25 ) 26 27 DATA_PATH = Path(__file__).with_name("data") 28 29 30 def test_beta_1_release(): 31 buglist_str_54_0b1 = create_bugs_url( 32 product="firefox", 33 current_version=GeckoVersion.parse("54.0b1"), 34 current_revision="cf76e00dcd6f", 35 ) 36 assert buglist_str_54_0b1 == "", "There should be no bugs to compare for beta 1." 37 38 39 @pytest.mark.parametrize( 40 "description,is_excluded", 41 ( 42 ( 43 "something something something a=test-only something something something", 44 True, 45 ), 46 ("this is a a=release change!", True), 47 ), 48 ) 49 def test_is_excluded_change(description, is_excluded): 50 assert is_excluded_change({"desc": description}) == is_excluded 51 52 53 @pytest.mark.parametrize( 54 "description,is_backout", 55 ( 56 ("I backed out this bug because", True), 57 ("Backing out this bug due to", True), 58 ("Backout bug xyz", True), 59 ("Back out bug xyz", True), 60 ("this is a regular bug description", False), 61 ), 62 ) 63 def test_is_backout_bug(description, is_backout): 64 assert is_backout_bug(description) == is_backout 65 66 67 @pytest.mark.parametrize( 68 "product,version,tag", 69 ( 70 ("firefox", GeckoVersion.parse("53.0b10"), "FIREFOX_53_0b10_RELEASE"), 71 ("firefox", GeckoVersion.parse("52.0"), "FIREFOX_52_0_RELEASE"), 72 ("fennec", GeckoVersion.parse("52.0.2"), "FENNEC_52_0_2_RELEASE"), 73 ), 74 ) 75 def test_tag_version(product, version, tag): 76 assert tag_version(product, version) == tag 77 78 79 @pytest.mark.parametrize( 80 "tag,version", 81 ( 82 ("FIREFOX_53_0b10_RELEASE", GeckoVersion.parse("53.0b10")), 83 ("FIREFOX_52_0_RELEASE", GeckoVersion.parse("52.0")), 84 ("FENNEC_52_0_2_RELEASE", GeckoVersion.parse("52.0.2")), 85 ), 86 ) 87 def test_parse_tag_version(tag, version): 88 assert parse_tag_version(tag) == version 89 90 91 @pytest.mark.parametrize( 92 "version,tag,previous_tag", 93 ( 94 ( 95 GeckoVersion.parse("48.0b4"), 96 "FIREFOX_48_0b4_RELEASE", 97 "FIREFOX_48_0b3_RELEASE", 98 ), 99 ( 100 GeckoVersion.parse("48.0b9"), 101 "FIREFOX_48_0b9_RELEASE", 102 "FIREFOX_48_0b7_RELEASE", 103 ), 104 ( 105 GeckoVersion.parse("48.0.2"), 106 "FIREFOX_48_0_2_RELEASE", 107 "FIREFOX_48_0_1_RELEASE", 108 ), 109 ( 110 GeckoVersion.parse("48.0.1"), 111 "FIREFOX_48_0_1_RELEASE", 112 "FIREFOX_48_0_RELEASE", 113 ), 114 ), 115 ) 116 def test_get_previous_tag_version(version, tag, previous_tag): 117 product = "firefox" 118 ff_48_tags = [ 119 "FIREFOX_BETA_48_END", 120 "FIREFOX_RELEASE_48_END", 121 "FIREFOX_48_0_2_RELEASE", 122 "FIREFOX_48_0_2_BUILD1", 123 "FIREFOX_48_0_1_RELEASE", 124 "FIREFOX_48_0_1_BUILD3", 125 "FIREFOX_48_0_RELEASE", 126 "FIREFOX_48_0_BUILD2", 127 "FIREFOX_RELEASE_48_BASE", 128 "FIREFOX_48_0b10_RELEASE", 129 "FIREFOX_48_0b10_BUILD1", 130 "FIREFOX_48_0b9_RELEASE", 131 "FIREFOX_48_0b9_BUILD1", 132 "FIREFOX_48_0b7_RELEASE", 133 "FIREFOX_48_0b7_BUILD1", 134 "FIREFOX_48_0b6_RELEASE", 135 "FIREFOX_48_0b6_BUILD1", 136 "FIREFOX_48_0b5_RELEASE", 137 "FIREFOX_48_0b5_BUILD1", 138 "FIREFOX_48_0b4_RELEASE", 139 "FIREFOX_48_0b4_BUILD1", 140 "FIREFOX_48_0b3_RELEASE", 141 "FIREFOX_48_0b3_BUILD1", 142 "FIREFOX_48_0b2_RELEASE", 143 "FIREFOX_48_0b2_BUILD2", 144 "FIREFOX_48_0b1_RELEASE", 145 "FIREFOX_48_0b1_BUILD2", 146 "FIREFOX_AURORA_48_END", 147 "FIREFOX_BETA_48_BASE", 148 "FIREFOX_AURORA_48_BASE", 149 ] 150 151 mock_hg_json = {"tags": [{"tag": ff_48_tag} for ff_48_tag in ff_48_tags]} 152 153 assert get_previous_tag_version(product, version, tag, mock_hg_json) == previous_tag 154 155 156 def test_get_bugs_in_changeset(): 157 with DATA_PATH.joinpath("buglist_changesets.json").open("r") as fp: 158 changeset_data = json.load(fp) 159 bugs, backouts = get_bugs_in_changeset(changeset_data) 160 161 assert bugs == { 162 "1356563", 163 "1348409", 164 "1341190", 165 "1360626", 166 "1332731", 167 "1328762", 168 "1355870", 169 "1358089", 170 "1354911", 171 "1354038", 172 } 173 assert backouts == {"1337861", "1320072"} 174 175 176 if __name__ == "__main__": 177 mozunit.main()