示例#1
0
文件: gomocks.py 项目: shitz/scion
 def main(self):
     rules = mock_rules()
     bazel = plumbum.local['bazel']
     bazel("build", rules)
     for rule in rules:
         bf, wf = rule_to_file(rule)
         cmd.diff(bf, wf)
示例#2
0
def test_default_settings(tmp_path: Path, any_odoo_version: float,
                          cloned_template: Path):
    """Prueba que una plantilla renderizada de cero este OK para cada version.

    No se dan parámetros aparte de odoo_version. Esto prueba que los andamios
    funcionan bien con respuestas predeterminadas.
    """
    dst = tmp_path / f"v{any_odoo_version:.1f}"
    with local.cwd(cloned_template):
        copy(
            ".",
            str(dst),
            vcs_ref="test",
            force=True,
            data={"odoo_version": any_odoo_version},
        )
    with local.cwd(dst):
        # TODO When copier runs pre-commit before extracting diff, make sure
        # here that it works as expected
        Path(dst, "odoo", "auto", "addons").rmdir()
        Path(dst, "odoo", "auto").rmdir()
        git("add", ".")
        git("commit", "-am", "Hello World", retcode=1)  # pre-commit fails
        git("commit", "-am", "Hello World")
    # El resultado coincide con lo que esperamos.
    diff(
        "--context=3",
        "--exclude=.git",
        "--recursive",
        local.cwd / "tests" / "default_settings" / f"v{any_odoo_version:.1f}",
        dst,
    )
示例#3
0
def test_default_settings(tmp_path: Path, any_odoo_version: float,
                          cloned_template: Path):
    """Test that a template rendered from zero is OK for each version.

    No params are given apart from odoo_version. This tests that scaffoldings
    render fine with default answers.
    """
    dst = tmp_path / f"v{any_odoo_version:.1f}"
    with local.cwd(cloned_template):
        copy(
            ".",
            str(dst),
            vcs_ref="test",
            force=True,
            data={"odoo_version": any_odoo_version},
        )
    with local.cwd(dst):
        # TODO When copier runs pre-commit before extracting diff, make sure
        # here that it works as expected
        Path(dst, "odoo", "auto", "addons").rmdir()
        Path(dst, "odoo", "auto").rmdir()
        git("add", ".")
        git("commit", "-am", "Hello World", retcode=1)  # pre-commit fails
        git("commit", "-am", "Hello World")
    # The result matches what we expect
    diff(
        "--context=3",
        "--exclude=.git",
        "--recursive",
        local.cwd / "tests" / "default_settings" / f"v{any_odoo_version:.1f}",
        dst,
    )
示例#4
0
def test_mqt_configs_synced(tmp_path: Path, cloned_template: Path,
                            any_odoo_version: float):
    """Make sure configs from MQT are in sync."""
    copy(
        str(cloned_template),
        str(tmp_path),
        vcs_ref="test",
        force=True,
        data={"odoo_version": any_odoo_version},
    )
    tmp_oca_path = tmp_path / ".." / "oca-addons-repo-files"
    tmp_oca_path.mkdir()
    copy(
        str(Path("vendor", "oca-addons-repo-template")),
        tmp_oca_path,
        vcs_ref="HEAD",
        force=True,
        data={
            "odoo_version":
            any_odoo_version if any_odoo_version >= 13 else "13.0"
        },
        exclude=["**", "!.pylintrc*"],
    )
    good_diffs = Path("tests", "samples", "mqt-diffs")
    for conf in (".pylintrc", ".pylintrc-mandatory"):
        good = (good_diffs / f"v{any_odoo_version}-{conf}.diff").read_text()
        tested = diff(tmp_path / conf, tmp_oca_path / conf, retcode=1)
        assert good == tested
示例#5
0
def test_mqt_configs_synced():
    """Make sure configs from MQT are in sync."""
    template = Path("tests", "default_settings", "v13.0")
    mqt = Path("vendor", "maintainer-quality-tools", "sample_files",
               "pre-commit-13.0")
    good_diffs = Path("tests", "samples", "mqt-diffs")
    for conf in (".pylintrc", ".pylintrc-mandatory"):
        good = (good_diffs / f"{conf}.diff").read_text()
        tested = diff(template / conf, mqt / conf, retcode=1)
        assert good == tested
示例#6
0
def test_mqt_configs_synced():
    """Asegurese de que las configuraciones de MQT esten sincronizadas."""
    template = Path("tests", "default_settings", "v13.0")
    mqt = Path("vendor", "maintainer-quality-tools", "sample_files",
               "pre-commit-13.0")
    good_diffs = Path("tests", "samples", "mqt-diffs")
    for conf in (".pylintrc", ".pylintrc-mandatory"):
        good = (good_diffs / f"{conf}.diff").read_text()
        tested = diff(template / conf, mqt / conf, retcode=1)
        assert good == tested
def test_mqt_configs_synced(tmp_path: Path, cloned_template: Path,
                            any_odoo_version: float):
    """Make sure configs from MQT are in sync."""
    copy(
        str(cloned_template),
        str(tmp_path),
        vcs_ref="test",
        force=True,
        data={"odoo_version": any_odoo_version},
    )
    mqt = Path("vendor", "maintainer-quality-tools", "sample_files",
               "pre-commit-13.0")
    good_diffs = Path("tests", "samples", "mqt-diffs")
    for conf in (".pylintrc", ".pylintrc-mandatory"):
        good = (good_diffs / f"v{any_odoo_version}-{conf}.diff").read_text()
        tested = diff(tmp_path / conf, mqt / conf, retcode=1)
        assert good == tested
示例#8
0
def replace_attribute(module_name, attribute_name, new_value, dry_run=True):
    """Update a metadata attribute"""
    init_file = '%s/__init__.py' % module_name
    _, tmp_file = tempfile.mkstemp()

    with open(init_file) as input_file:
        with open(tmp_file, 'w') as output_file:
            for line in input_file:
                if line.startswith(attribute_name):
                    line = "%s = '%s'\n" % (attribute_name, new_value)

                output_file.write(line)

    if not dry_run:
        Path(tmp_file).copy(init_file)
    else:
        log.info(diff(tmp_file, init_file, retcode=None))
示例#9
0
def replace_attribute(module_name, attribute_name, new_value, dry_run=True):
    """Update a metadata attribute"""
    init_file = '%s/__init__.py' % module_name
    _, tmp_file = tempfile.mkstemp()

    with open(init_file) as input_file:
        with open(tmp_file, 'w') as output_file:
            for line in input_file:
                if line.startswith(attribute_name):
                    line = "%s = '%s'\n" % (attribute_name, new_value)

                output_file.write(line)

    if not dry_run:
        path(tmp_file).move(init_file)
    else:
        log.info(diff(tmp_file, init_file, retcode=None))