示例#1
0
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
示例#2
0
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
示例#3
0
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"
示例#4
0
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
示例#5
0
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
示例#6
0
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
示例#7
0
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
示例#8
0
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
示例#9
0
def test_repository_helpers_properties_can_be_installed():
    repository = HacsRepository()
    assert repository.can_be_installed