def dummy_repository_base(repository=None): if repository is None: repository = HacsRepository() repository.hacs.hass = HomeAssistant() repository.hacs.hass.data = {"custom_components": []} repository.logger = Logger("hacs.test.test") repository.data.full_name = "test/test" repository.versions.available = "3" repository.status.selected_tag = "3" repository.ref = version_to_install(repository) repository.integration_manifest = {"config_flow": False, "domain": "test"} repository.releases.published_tags = ["1", "2", "3"] repository.data.update_data(repository_data) return repository
def test_repository_helpers_properties_pending_update(): repository = HacsRepository() repository.hacs.system.ha_version = "0.109.0" repository.data.homeassistant = "0.110.0" repository.data.releases = True assert not repository.pending_update repository = HacsRepository() repository.data.installed = True repository.data.default_branch = "master" repository.data.selected_tag = "master" assert not repository.pending_update repository.data.installed_commit = "1" repository.data.last_commit = "2" assert repository.pending_update
def test_restore_repository_data(): repo = HacsRepository() data = { "description": "test", "installed": True, "full_name": "hacs/integration" } restore_repository_data(repo, data) assert repo.data.description == "test"
def test_hacs_repository_core_can_install_manifest(): repository = HacsRepository() repository.system.ha_version = "1.0.0" repository.releases.releases = True repository.repository_manifest.homeassistant = "1.1.0" assert not repository.can_install repository.repository_manifest.homeassistant = "0.1.0" assert repository.can_install
def test_hacs_repository_core_can_install_legacy(): repository = HacsRepository() repository.system.ha_version = "1.0.0" repository.releases.releases = True repository.information.homeassistant_version = "1.1.0" assert not repository.can_install repository.information.homeassistant_version = "0.1.0" assert repository.can_install
def test_hacs_can_install(): hacs = get_hacs() repository = HacsRepository() repository.repository_manifest = {"test": "test"} repository.releases.releases = True hacs.system.ha_version = "1.0.0" repository.data.homeassistant = "1.0.0b1" assert repository.can_install hacs.system.ha_version = "1.0.0b1" repository.data.homeassistant = "1.0.0" assert not repository.can_install hacs.system.ha_version = "1.0.0b1" repository.data.homeassistant = "1.0.0b2" assert not repository.can_install hacs.system.ha_version = "1.0.0" repository.data.homeassistant = "1.0.0" assert repository.can_install
def test_repository_helpers_properties_custom(): repository = HacsRepository() repository.data.full_name = "custom-components/test" assert not repository.custom repository.data.full_name = "test/test" assert repository.custom repository.data.id = 1337 repository.hacs.common.default.append(repository.data.id) assert not repository.custom repository.hacs.common.default = [] assert repository.custom repository.data.full_name = "hacs/integration" assert not repository.custom
def test_hacs_repository_core_mostly_defaults(): repository = HacsRepository() repository.data.full_name = "developer/repository" repository.data.default_branch = "master" repository.data.description = "Awesome GitHub repository" assert repository.display_name == "Repository" assert repository.custom assert repository.display_status == "new" assert repository.display_status_description == "This is a newly added repository." assert repository.main_action == "INSTALL" assert repository.display_version_or_commit == "commit" assert repository.display_available_version == "" assert repository.display_installed_version == "" assert repository.can_install assert not repository.pending_upgrade
def test_repository_helpers_properties_can_be_installed(): repository = HacsRepository() assert repository.can_be_installed