def test_find_all_parents_returns_empty_list_if_framework_has_no_parent():
    frameworks = Namespace(
        gama=Namespace(name="gama", version="latest", description="flexible automl"),
        h2o_automl=Namespace(name="h2o", version="1.3"),
    )
    parents = _find_all_parents(frameworks.gama, frameworks)
    assert parents == []
def test_find_all_parents_returns_parent_of_framework_with_single_parent(framework):
    frameworks = Namespace(
        gama=Namespace(name="gama", version="latest", description="flexible automl"),
        gama_old=Namespace(name="gama_20.1.0", version="20.1.0", extends="gama"),
        h2o_automl=Namespace(name="h2o", version="latest"),
        h2o_automl_old=Namespace(name="h2o_1.2", version="1.2", extends="h2o_automl"),
    )
    parents = _find_all_parents(frameworks[f"{framework}_old"], frameworks)
    assert parents == [frameworks[framework]]
def test_find_all_parents_returns_frameworks_closest_first_if_two_parents(framework):
    frameworks = Namespace(
        gama=Namespace(name="gama", version="latest", description="flexible automl"),
        gama_old=Namespace(name="gama_20.1.0", version="20.1.0", extends="gama"),
        gama_older=Namespace(name="gama_20.0.0", version="20.0.0", extends="gama_old"),
        h2o_automl=Namespace(name="h2o", version="latest"),
        h2o_automl_old=Namespace(name="h2o_1.2", version="1.2", extends="h2o_automl"),
        h2o_automl_older=Namespace(name="h2o_1.1", version="1.1", extends="h2o_automl_old"),
    )
    parents = _find_all_parents(frameworks[f"{framework}_older"], frameworks)
    assert parents == [frameworks[f"{framework}_old"], frameworks[framework]]
def test_find_all_parents_ignores_when_extends_is_none():
    frameworks = Namespace(
        gama=Namespace(name="gama", version="latest", extends=None),
    )
    assert _find_all_parents(frameworks.gama, frameworks) == [], """