Tuesday, February 20, 2018

quality interactive tests with Lynx, the server-side browser

Working on a web page test on a server, but can't view the page in a normal web browser? It's easy enough to transfer the HTML to your local computer, or... use a text-mode browser!

The Lynx browser is tiny, fast, and supports a good part of modern web pages. It's a great tool for quickly getting a rough idea of what your page looks like.

Example: my Flask app refuses to handle authentication correctly. So, I write a API test to log in to myserver, capture the response, then write it to a server-side HTML file.  Next I use Lynx to view it so I can see what it's doing!

Here's my Registration test:

def test_post(client):
    "validate page that uses POST"
    rv = client.post('/auth/register', data=dict(
    if 1:
        with open('zoot.html', 'w') as pagef:

Run the test


Next, use the server-side browser to view my output:

lynx -dump -stdin < zoot.html


   (BUTTON) Toggle navigation [1]test
     * [2]Home

     * [3]Log In


   Email test@example.com____
   Username test________________
   Password ____________________

   Passwords must match.
   Confirm password ____________________

   This field is required.

Note the "Passwords must match" bit. Ah, there's my bug. In the POST I'd forgotten to send both the password and validating password2 fields.  Bug fixed, thanks to Lynx!

Wednesday, February 7, 2018

Terraform and iTerm2 FTW

1) install imgcat from iTerm2 page
2) brew install graphviz

Now, when you're working on a complex set of Terraform dependencies, you can display them directly in your terminal!

terraform graph | dot -Tpng | imgcat

(Code from the excellent book Terraform: Up and Running by Yevgeniy Brikman.)