def can_be_installed(self) -> bool:
     if self.data.homeassistant is not None:
         if self.data.releases:
             if not version_left_higher_then_right(
                     self.hacs.core.ha_version, self.data.homeassistant):
                 return False
     return True
Example #2
0
def test_wierd_stuff():
    assert version_left_higher_then_right("1.0.0rc1", "1.0.0b1")
    assert not version_left_higher_then_right("1.0.0a1", "1.0.0b1")
    assert version_left_higher_then_right("1.0.0", "1.0.0a0")
    assert version_left_higher_then_right("1.0.0", "1.0.0b0")
    assert version_left_higher_then_right("1.0.0", "1.0.0rc0")
    assert not version_left_higher_then_right(None, "1.0.0rc0")
    assert not version_left_higher_then_right(1.0, "1.0.0rc0")
    assert not version_left_higher_then_right({}, "1.0.0rc0")
Example #3
0
def test_basic():
    assert version_left_higher_then_right("1.0.0", "0.9.9")
    assert version_left_higher_then_right("1", "0.9.9")
    assert version_left_higher_then_right("1.1", "0.9.9")
    assert version_left_higher_then_right("0.10.0", "0.9.9")
    assert not version_left_higher_then_right("0.0.10", "0.9.9")
    assert not version_left_higher_then_right("0.9.0", "0.9.9")
    assert version_left_higher_then_right("1.0.0", "1.0.0")
Example #4
0
def constrain_version():
    """Check if the version is valid."""
    hacs = get_hacs()
    if not version_left_higher_then_right(hacs.system.ha_version,
                                          MINIMUM_HA_VERSION):
        hacs.log.critical(
            f"You need HA version {MINIMUM_HA_VERSION} or newer to use this integration."
        )
        return False
    return True
Example #5
0
def test_beta():
    assert version_left_higher_then_right("1.0.0b1", "1.0.0b0")
    assert not version_left_higher_then_right("1.0.0b1", "1.0.0")
    assert version_left_higher_then_right("1.0.0", "1.0.0b1")