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)
def test_check_constrains(tmpdir): hacs = get_hacs() hacs.system.ha_version = HAVERSION hacs.system.config_path = tmpdir.dirname assert not check_constrains() 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_constrains() 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_constrains() 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_constrains() assert constrain_translations() temp_cleanup(tmpdir)
def test_ha_version(tmpdir): hacs = get_hacs() hacs.system.config_path = tmpdir.dirname translations_dir = f"{hacs.system.config_path}/custom_components/hacs/translations" os.makedirs(translations_dir, exist_ok=True) hacs.system.ha_version = HAVERSION assert constrain_version() hacs.system.ha_version = "1.0.0" assert constrain_version() hacs.system.ha_version = "0.97.0" assert not constrain_version() temp_cleanup(tmpdir)
def test_ha_version(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 constrain_version(hacs) with open(f"{manifest_dir}/manifest.json", "w") as manifest: manifest.write(json.dumps({"homeassistant": "9.99.8"})) assert constrain_version(hacs) with open(f"{manifest_dir}/manifest.json", "w") as manifest: manifest.write(json.dumps({"homeassistant": "10.0.0"})) assert not constrain_version(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) assert constrain_version(hacs) assert check_constans(hacs) assert constrain_translations(hacs) temp_cleanup(tmpdir)