Ejemplo n.º 1
0
def test_gecko_version_ensures_it_does_not_have_multiple_type(
        monkeypatch, version_string):
    # Let's make sure the sanity checks detect a broken regular expression
    original_pattern = GeckoVersion._VALID_ENOUGH_VERSION_PATTERN
    GeckoVersion._VALID_ENOUGH_VERSION_PATTERN = _SUPER_PERMISSIVE_PATTERN

    with pytest.raises(TooManyTypesError):
        GeckoVersion.parse(version_string)

    GeckoVersion._VALID_ENOUGH_VERSION_PATTERN = original_pattern
def test_beta_1_release():
    buglist_str_54_0b1 = create_bugs_url(
        product='firefox',
        current_version=GeckoVersion.parse('54.0b1'),
        current_revision='cf76e00dcd6f',
    )
    assert buglist_str_54_0b1 == '', 'There should be no bugs to compare for beta 1.'
Ejemplo n.º 3
0
def test_beta_1_release():
    buglist_str_54_0b1 = create_bugs_url(
        product="firefox",
        current_version=GeckoVersion.parse("54.0b1"),
        current_revision="cf76e00dcd6f",
    )
    assert buglist_str_54_0b1 == "", "There should be no bugs to compare for beta 1."
Ejemplo n.º 4
0
    def gather_info(self):
        from mozilla_version.gecko import GeckoVersion

        self._get_update_paths()
        if self.update_paths:
            self.log("Found update paths:", level=DEBUG)
            self.log(pprint.pformat(self.update_paths), level=DEBUG)
        elif (GeckoVersion.parse(self.config["to_version"]) <=
              GeckoVersion.parse(self.config["last_watershed"])):
            self.log(
                "Didn't find any update paths, but to_version {} is before the last_"
                "watershed {}, generating empty config".format(
                    self.config['to_version'],
                    self.config['last_watershed'],
                ),
                level=WARNING,
            )
        else:
            self.log("Didn't find any update paths, cannot continue",
                     level=FATAL)
Ejemplo n.º 5
0
def check_versions_are_successive(current_version, payload_version):
    current_bouncer_version = GeckoVersion.parse(current_version)
    candidate_version = GeckoVersion.parse(payload_version)

    if current_bouncer_version.major_number == candidate_version.major_number:
        err_msg = ("At this point, in-tree version can't be equal to bouncer "
                   "counterpart".format(payload_version, current_version))
        raise ScriptWorkerTaskException(err_msg)
    elif current_bouncer_version.major_number > candidate_version.major_number:
        err_msg = ("In-tree version {} can't be less than current bouncer "
                   "counterpart".format(payload_version, current_version))
        raise ScriptWorkerTaskException(err_msg)
    elif (candidate_version.major_number -
          current_bouncer_version.major_number) > 1:
        err_msg = ("In-tree version {} can't be greater than current bouncer "
                   "by more than 1 digit".format(payload_version,
                                                 current_version))
        raise ScriptWorkerTaskException(err_msg)

    log.info("Versions are successive. All good")
    def _get_branch_url(self, branch_prefix, version):
        version = GeckoVersion.parse(version)
        branch = None
        if version.version_type == VersionType.BETA:
            branch = "releases/{}-beta".format(branch_prefix)
        elif version.version_type == VersionType.ESR:
            branch = "releases/{}-esr{}".format(branch_prefix, version.major_number)
        elif version.version_type == VersionType.RELEASE:
            if branch_prefix == "comm":
                # Thunderbird does not have ESR releases, regular releases
                # go in an ESR branch
                branch = "releases/{}-esr{}".format(branch_prefix, version.major_number)
            else:
                branch = "releases/{}-release".format(branch_prefix)
        if not branch:
            raise Exception("Cannot determine branch, cannot continue!")

        return branch
Ejemplo n.º 7
0
def generate_update_line(config, jobs):
    """Resolve fields that can be keyed by platform, etc."""
    release_config = get_release_config(config)
    for job in jobs:
        config_file = job.pop('whats-new-config')
        update_config = load_yaml(config_file)

        product = job['shipping-product']
        if product == 'devedition':
            product = 'firefox'
        job['worker']['update-line'] = {}
        for blob_type, suffix in [('wnp', ''), ('no-wnp', '-No-WNP')]:
            context = {
                'release-type': config.params['release_type'],
                'product': product,
                'version': GeckoVersion.parse(release_config['appVersion']),
                'blob-type': blob_type,
            }
            job['worker']['update-line'][suffix] = generate_update_properties(
                context, update_config)

        yield job
Ejemplo n.º 8
0
def generate_update_line(config, jobs):
    """Resolve fields that can be keyed by platform, etc."""
    release_config = get_release_config(config)
    for job in jobs:
        config_file = job.pop("whats-new-config")
        update_config = load_yaml(config_file)

        product = job["shipping-product"]
        if product == "devedition":
            product = "firefox"
        job["worker"]["update-line"] = {}
        for blob_type, suffix in [("wnp", ""), ("no-wnp", "-No-WNP")]:
            context = {
                "release-type": config.params["release_type"],
                "product": product,
                "version": GeckoVersion.parse(release_config["appVersion"]),
                "blob-type": blob_type,
                "build-id": config.params["moz_build_date"],
            }
            job["worker"]["update-line"][suffix] = generate_update_properties(
                context, update_config
            )

        yield job
Ejemplo n.º 9
0
def test_gecko_version_hashable():
    """
    It is possible to hash `GeckoVersion`.
    """
    hash(GeckoVersion.parse('63.0'))
Ejemplo n.º 10
0
def test_gecko_version_bump_version_type_fail(version_string):
    version = GeckoVersion.parse(version_string)
    with pytest.raises(ValueError):
        version.bump_version_type()
Ejemplo n.º 11
0
def test_gecko_version_bump_version_type(version_string, expected):
    version = GeckoVersion.parse(version_string)
    assert str(version.bump_version_type()) == expected
Ejemplo n.º 12
0
def test_gecko_version_supports_old_schemes(version_string):
    assert str(GeckoVersion.parse(version_string)) == version_string
Ejemplo n.º 13
0
def test_gecko_version_raises_multiple_error_messages():
    with pytest.raises(PatternNotMatchedError) as exc_info:
        GeckoVersion.parse('5.0.0.1rc1')

    assert exc_info.value.args[
        0] == '''"5.0.0.1rc1" does not match the patterns:
Ejemplo n.º 14
0
    (
        ("I backed out this bug because", True),
        ("Backing out this bug due to", True),
        ("Backout bug xyz", True),
        ("Back out bug xyz", True),
        ("this is a regular bug description", False),
    ),
)
def test_is_backout_bug(description, is_backout):
    assert is_backout_bug(description) == is_backout


@pytest.mark.parametrize(
    "product,version,tag",
    (
        ("firefox", GeckoVersion.parse("53.0b10"), "FIREFOX_53_0b10_RELEASE"),
        ("firefox", GeckoVersion.parse("52.0"), "FIREFOX_52_0_RELEASE"),
        ("fennec", GeckoVersion.parse("52.0.2"), "FENNEC_52_0_2_RELEASE"),
    ),
)
def test_tag_version(product, version, tag):
    assert tag_version(product, version) == tag


@pytest.mark.parametrize(
    "tag,version",
    (
        ("FIREFOX_53_0b10_RELEASE", GeckoVersion.parse("53.0b10")),
        ("FIREFOX_52_0_RELEASE", GeckoVersion.parse("52.0")),
        ("FENNEC_52_0_2_RELEASE", GeckoVersion.parse("52.0.2")),
    ),
Ejemplo n.º 15
0
def check_version_matches_nightly_regex(version):
    version = GeckoVersion.parse(version)
    if not version.is_nightly:
        raise ScriptWorkerTaskException(
            "Version {} is valid but does not match a nightly one")
Ejemplo n.º 16
0
def test_gecko_version_implements_remaining_comparision_operators():
    assert GeckoVersion.parse('32.0') <= GeckoVersion.parse('32.0')
    assert GeckoVersion.parse('32.0') <= GeckoVersion.parse('33.0')

    assert GeckoVersion.parse('33.0') >= GeckoVersion.parse('32.0')
    assert GeckoVersion.parse('33.0') >= GeckoVersion.parse('33.0')

    assert GeckoVersion.parse('33.0') > GeckoVersion.parse('32.0')
    assert not GeckoVersion.parse('33.0') > GeckoVersion.parse('33.0')

    assert not GeckoVersion.parse('32.0') < GeckoVersion.parse('32.0')

    assert GeckoVersion.parse('33.0') != GeckoVersion.parse('32.0')
Ejemplo n.º 17
0
def test_gecko_version_raises_eq_operator(wrong_type):
    with pytest.raises(ValueError):
        assert GeckoVersion.parse('32.0') == wrong_type
    # AttributeError is raised by LooseVersion and StrictVersion
    with pytest.raises((ValueError, AttributeError)):
        assert wrong_type == GeckoVersion.parse('32.0')
Ejemplo n.º 18
0
def test_gecko_version_implements_eq_operator(equivalent_version_string):
    assert GeckoVersion.parse('32.0') == GeckoVersion.parse(
        equivalent_version_string)
    # raw strings are also converted
    assert GeckoVersion.parse('32.0') == equivalent_version_string
Ejemplo n.º 19
0
def test_gecko_version_implements_lt_operator(previous, next):
    assert GeckoVersion.parse(previous) < GeckoVersion.parse(next)
Ejemplo n.º 20
0
def test_gecko_version_is_of_a_defined_type(version_string, expected_type):
    release = GeckoVersion.parse(version_string)
    assert getattr(release, 'is_{}'.format(expected_type))
Ejemplo n.º 21
0
import json
from mozrelease.util import load as yaml_load
from pathlib2 import Path

from mozrelease.balrog import generate_update_properties
from mozilla_version.gecko import GeckoVersion

DATA_PATH = Path(__file__).parent.joinpath('data')


@pytest.mark.parametrize('context,config_file,output_file', [
    ({
        'release-type': 'release',
        'product': 'firefox',
        'version': GeckoVersion.parse('62.0.3'),
    }, 'whatsnew-62.0.3.yml', 'Firefox-62.0.3.update.json'),
    ({
        'release-type': 'beta',
        'product': 'firefox',
        'version': GeckoVersion.parse('64.0'),
    }, 'whatsnew-62.0.3.yml', 'Firefox-64.0b13.update.json'),
])
def test_update_properties(context, config_file, output_file):
    with DATA_PATH.joinpath(config_file).open('r', encoding='utf-8') as f:
        config = yaml_load(f)

    update_line = generate_update_properties(context, config)

    assert update_line == json.load(
        DATA_PATH.joinpath(output_file).open('r', encoding='utf-8'))
Ejemplo n.º 22
0
from pathlib2 import Path

from mozrelease.balrog import generate_update_properties
from mozilla_version.gecko import GeckoVersion

DATA_PATH = Path(__file__).parent.joinpath("data")


@pytest.mark.parametrize(
    "context,config_file,output_file",
    [
        (
            {
                "release-type": "release",
                "product": "firefox",
                "version": GeckoVersion.parse("62.0.3"),
            },
            "whatsnew-62.0.3.yml",
            "Firefox-62.0.3.update.json",
        ),
        (
            {
                "release-type": "beta",
                "product": "firefox",
                "version": GeckoVersion.parse("64.0"),
            },
            "whatsnew-62.0.3.yml",
            "Firefox-64.0b13.update.json",
        ),
    ],
)
Ejemplo n.º 23
0
def test_gecko_version_bump_raises(version_string, field):
    version = GeckoVersion.parse(version_string)
    with pytest.raises(ValueError):
        version.bump(field)
    assert is_excluded_change({'desc': description}) == is_excluded


@pytest.mark.parametrize('description,is_backout', (
    ('I backed out this bug because', True),
    ('Backing out this bug due to', True),
    ('Backout bug xyz', True),
    ('Back out bug xyz', True),
    ('this is a regular bug description', False),
))
def test_is_backout_bug(description, is_backout):
    assert is_backout_bug(description) == is_backout


@pytest.mark.parametrize('product,version,tag', (
    ('firefox', GeckoVersion.parse('53.0b10'), 'FIREFOX_53_0b10_RELEASE'),
    ('firefox', GeckoVersion.parse('52.0'), 'FIREFOX_52_0_RELEASE'),
    ('fennec', GeckoVersion.parse('52.0.2'), 'FENNEC_52_0_2_RELEASE'),
))
def test_tag_version(product, version, tag):
    assert tag_version(product, version) == tag


@pytest.mark.parametrize('tag,version', (
    ('FIREFOX_53_0b10_RELEASE', GeckoVersion.parse('53.0b10')),
    ('FIREFOX_52_0_RELEASE', GeckoVersion.parse('52.0')),
    ('FENNEC_52_0_2_RELEASE', GeckoVersion.parse('52.0.2')),
))
def test_parse_tag_version(tag, version):
    assert parse_tag_version(tag) == version
Ejemplo n.º 25
0
def parse_tag_version(tag):
    dot_version = ".".join(tag.split("_")[1:-1])
    return GeckoVersion.parse(dot_version)
Ejemplo n.º 26
0
def test_gecko_version_implements_str_operator(version_string,
                                               expected_output):
    assert str(GeckoVersion.parse(version_string)) == expected_output
Ejemplo n.º 27
0
def test_gecko_version_raises_when_invalid_version_is_given(
        version_string, ExpectedErrorType):
    with pytest.raises(ExpectedErrorType):
        GeckoVersion.parse(version_string)
Ejemplo n.º 28
0
def parse_tag_version(tag):
    dot_version = '.'.join(tag.split('_')[1:-1])
    return GeckoVersion.parse(dot_version)
Ejemplo n.º 29
0
def test_gecko_version_bump(version_string, field, expected):
    version = GeckoVersion.parse(version_string)
    assert str(version.bump(field)) == expected