def test_recursive_array() -> None:
    """Test a schema having a recursive definition pointing to array items"""
    soup = generate_case("recursive_array",
                         GenerationConfiguration(link_to_reused_ref=True))

    assert_descriptions(soup, [
        "A list of people", "A human being", "The children they had",
        "A human being"
    ])

    assert_ref_link(soup, "#person_items", "Same definition as person")
Esempio n. 2
0
def test_recursive_array() -> None:
    """Test a schema having a recursive definition pointing to array items"""
    soup = generate_case("recursive_array", link_to_reused_ref=True)

    assert_descriptions(soup, [
        "A list of people", "A human being", "The children they had",
        "A human being"
    ])

    recursive_definition_link = soup.find("a", href="#person_items")
    assert recursive_definition_link
    assert recursive_definition_link.text == "Same definition as person_items"
def test_recursive(link_to_reused_ref: bool) -> None:
    """Test a schema having a recursive definition.

    Even if `link_to_reused_ref` is False, a reference will be generated to avoid a RecursionError
    """
    soup = generate_case(
        "recursive",
        GenerationConfiguration(link_to_reused_ref=link_to_reused_ref))

    assert_descriptions(
        soup, ["A human being", "The children they had", "A human being"])

    assert_ref_link(soup, "#person", "Same definition as person")
Esempio n. 4
0
def test_recursive(link_to_reused_ref: bool) -> None:
    """Test a schema having a recursive definition.

    Even if `link_to_reused_ref` is False, a reference will be generated to avoid a RecursionError
    """
    soup = generate_case("recursive", link_to_reused_ref=link_to_reused_ref)

    assert_descriptions(
        soup, ["A human being", "The children they had", "A human being"])

    recursive_definition_link = soup.find("a", href="#person")
    assert recursive_definition_link
    assert recursive_definition_link.text == "Same definition as person"
def test_recursive_two_files(link_to_reused_ref: bool) -> None:
    """Test rendering a schema with a recursive definition with the same name, but in another file"""
    soup = generate_case(
        "recursive_two_files",
        GenerationConfiguration(link_to_reused_ref=link_to_reused_ref))

    assert_descriptions(
        soup,
        [
            "A human being",
            "The children they had",
            "Person definition from second file. Not the same!",
            "Person definition from second file. Not the same!",
        ],
    )

    if link_to_reused_ref:
        assert_ref_link(soup, "#person_siblings",
                        "Same definition as siblings")
    else:
        assert not get_ref_link(soup, "#person_siblings")
def test_recursive_parent_in_definition(link_to_reused_ref: bool) -> None:
    """Test a schema having a recursive definition. Moreover, the ref is linked to an attribute in a definition that
    has not been seen in the tree before

    Even if `link_to_reused_ref` is False, a reference will be generated to avoid a RecursionError
    """
    soup = generate_case(
        "recursive_parent_in_definition",
        GenerationConfiguration(link_to_reused_ref=link_to_reused_ref))

    assert_descriptions(
        soup,
        [
            "Relationships between this person and others",
            "A human being",
            "Relationships between this person and others",
            "A human being",
        ],
    )

    assert_ref_link(soup, "#relationships_mother", "Same definition as mother")
Esempio n. 7
0
def test_recursive_two_files(link_to_reused_ref: bool) -> None:
    """Test rendering a schema with a recursive definition with the same name, but in another file"""
    soup = generate_case("recursive_two_files",
                         link_to_reused_ref=link_to_reused_ref)

    assert_descriptions(
        soup,
        [
            "A human being",
            "The children they had",
            "Person definition from second file. Not the same!",
            "Person definition from second file. Not the same!",
        ],
    )

    recursive_definition_link = soup.find("a", href="#person_siblings")
    if link_to_reused_ref:
        assert recursive_definition_link
        assert recursive_definition_link.text == "Same definition as person_siblings"
    else:
        assert not recursive_definition_link
Esempio n. 8
0
def test_recursive_full_schema(link_to_reused_ref: bool) -> None:
    """Test a schema having a recursive definition.

    Even if `link_to_reused_ref` is False, a reference will be generated to avoid a RecursionError
    """
    soup = generate_case(
        "recursive_full_schema",
        GenerationConfiguration(link_to_reused_ref=link_to_reused_ref))

    assert_descriptions(
        soup,
        [
            "Display the issue.",
            "Code property",
            "RecursiveArray property",
            "Display the issue.",
            "DecoratedRecursiveArray property",
            "Display the issue.",
        ],
    )

    assert_ref_link(soup, "#root", "Same definition as Bug")