Пример #1
0
def test_check_constans(tmpdir):
    hacs = get_hacs()
    hacs.system.ha_version = HAVERSION
    hacs.system.config_path = tmpdir.dirname

    assert not check_constans()

    translations_dir = f"{hacs.system.config_path}/custom_components/hacs/.translations"
    os.makedirs(translations_dir, exist_ok=True)

    custom_updater_dir = f"{hacs.system.config_path}/custom_components/custom_updater"
    os.makedirs(custom_updater_dir, exist_ok=True)
    with open(f"{custom_updater_dir}/__init__.py", "w") as cufile:
        cufile.write("")

    assert not check_constans()
    temp_cleanup(tmpdir)

    translations_dir = f"{hacs.system.config_path}/custom_components/hacs/.translations"
    os.makedirs(translations_dir, exist_ok=True)

    hacs.system.ha_version = "0.97.0"
    assert not check_constans()

    hacs.system.ha_version = HAVERSION

    translations_dir = f"{hacs.system.config_path}/custom_components/hacs/.translations"
    os.makedirs(translations_dir, exist_ok=True)

    assert constrain_version()
    assert check_constans()
    assert constrain_translations()

    temp_cleanup(tmpdir)
Пример #2
0
def test_check_constans(tmpdir):
    hacs = Hacs()
    hacs.system.ha_version = HAVERSION
    hacs.system.config_path = tmpdir.dirname

    assert not check_constans(hacs)

    translations_dir = f"{hacs.system.config_path}/custom_components/hacs/.translations"
    os.makedirs(translations_dir, exist_ok=True)

    assert constrain_version(hacs)
    assert check_constans(hacs)
    assert constrain_translations(hacs)

    temp_cleanup(tmpdir)
def test_check_constans(tmpdir):
    hacs = Hacs()
    hacs.system.ha_version = HAVERSION
    hacs.system.config_path = tmpdir.dirname

    assert not check_constans(hacs)

    translations_dir = f"{hacs.system.config_path}/custom_components/hacs/.translations"
    os.makedirs(translations_dir, exist_ok=True)

    manifest_dir = f"{hacs.system.config_path}/custom_components/hacs"
    os.makedirs(manifest_dir, exist_ok=True)
    with open(f"{manifest_dir}/manifest.json", "w") as manifest:
        manifest.write(json.dumps({"homeassistant": "9.99.8"}))
    assert constrain_version(hacs)

    assert check_constans(hacs)

    temp_cleanup(tmpdir)
Пример #4
0
def test_check_constans(tmpdir):
    hacs = Hacs()
    hacs.system.ha_version = HAVERSION
    hacs.system.config_path = tmpdir.dirname

    manifest_dir = f"{hacs.system.config_path}/custom_components/hacs"
    os.makedirs(manifest_dir, exist_ok=True)

    with open(f"{manifest_dir}/manifest.json", "w") as manifest:
        manifest.write(json.dumps({"homeassistant": HAVERSION}))
    assert check_constans(hacs)

    with open(f"{manifest_dir}/manifest.json", "w") as manifest:
        manifest.write(json.dumps({"homeassistant": "10"}))
    assert not check_constans(hacs)

    custom_updater_dir = f"{hacs.system.config_path}/custom_components/custom_updater"
    os.makedirs(custom_updater_dir, exist_ok=True)
    with open(f"{custom_updater_dir}/__init__.py", "w") as cufile:
        cufile.write("")
    assert not check_constans(hacs)

    temp_cleanup(tmpdir)