def test_full_page_with_title():
    """
    not much to actually test here, but good to see it put together.

    everything should have already been tested.
    """
    page = HTML()

    head = Head()
    head.append(Title("PythonClass Example"))

    page.append(head)

    body = Body()

    body.append(
        Para("Here is a paragraph of text -- there could be more of them, "
             "but this is enough  to show that we can do some text"))
    body.append(
        Para(
            "And here is another piece of text -- you should be able to add any number"
        ))

    page.append(body)

    file_contents = render_element(page)

    print(file_contents)
def test_render_non_strings2():
    """
    Testing nested elements and text, in a more complex way
    """
    html = HTML()
    body = Body()
    html.append(body)
    p = Para('any string I like')
    p.append('even more random text')
    body.append(p)
    body.append(Para('and this is a different string'))
    contents = render_element(html).strip()

    print(contents)  # so we can see what's going on if a test fails

    # so what should the results be?
    # the html tag is the outer tag, so the contents should start and end with that.
    assert contents.startswith('<html>')
    assert contents.endswith('</html>')

    # the body tags had better be there too
    assert '<body>' in contents
    assert '</body' in contents

    # and two <p> tags
    assert contents.count('<p>')

    # we want the text, too:
    assert 'any string I like' in contents
    assert 'even more random text' in contents
    assert 'and this is a different string' in contents
def test_render_html():
    my_stuff = 'spam, spam, spam'
    el_object = HTML(my_stuff)
    more_stuff = 'eggs, eggs, eggs'
    el_object.append(more_stuff)
    contents = render_element(el_object)
    assert contents.startswith('<html>')
    assert contents.endswith('</html>')
    assert my_stuff in contents
    assert more_stuff in contents
def test_render_HTML():
    my_stuff = 'hamma, hamma, hamma'
    el_object = HTML(my_stuff)
    more_stuff = "umma, umma, umma"
    el_object.append(more_stuff)
    with open('testh', 'w') as out_file:
        el_object.render(out_file)
    with open('testh', 'r') as in_file:
        contents = in_file.read()
    assert contents.startswith('<html>')
    assert contents.endswith('</html>')
    assert my_stuff in contents
    assert more_stuff in contents