Esempio n. 1
0
def get_hacs():
    if not hacs:
        from custom_components.hacs.hacsbase import Hacs

        hacs.append(Hacs())

    return hacs[0]
Esempio n. 2
0
def test_translations(tmpdir):
    hacs = Hacs()
    hacs.system.config_path = tmpdir.dirname

    assert not constrain_translations(hacs)

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

    temp_cleanup(tmpdir)
Esempio n. 3
0
def test_ha_version(tmpdir):
    hacs = Hacs()
    hacs.system.config_path = tmpdir.dirname

    hacs.system.ha_version = HAVERSION
    assert constrain_version(hacs)

    hacs.system.ha_version = "1.0.0"
    assert constrain_version(hacs)

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

    temp_cleanup(tmpdir)
Esempio n. 4
0
def test_custom_updater(tmpdir):
    hacs = Hacs()
    hacs.system.config_path = tmpdir.dirname

    assert constrain_custom_updater(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 constrain_custom_updater(hacs)

    custom_updater_dir = f"{hacs.system.config_path}/custom_components"
    os.makedirs(custom_updater_dir, exist_ok=True)
    with open(f"{custom_updater_dir}/custom_updater.py", "w") as cufile:
        cufile.write("")
    assert not constrain_custom_updater(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)
Esempio n. 6
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)