This line will raise a KeyError if 'formula' doesn't exist, so the next line won't work in practice.  There's a test of 'formula':None, but there's no test of a missing 'formula' key, which is what will happen with a bad POST.