# {{{ Imports
from mysite.base.tests import make_twill_url, TwillTests
# }}}

class Form(TwillTests):
    fixtures = ['person-paulproteus.json', 'user-paulproteus.json']

    def test_form_post_handler(self):
        client = self.login_with_client()
        json = client.post('/senseknocker/handle_form', {
                    'before': 'I was singing "Ave Maria" to a potful of dal.', 
                    'expected_behavior': 'I expected the dal to be stirred.', 
                    'actual_behavior': 'Instead, burnination.'})
        # Once we have a bug tracker,
        # check that the POST handler actually added a bug.
        self.assertEqual(json.content, '[{"success": 1}]')

@@ -256,78 +256,20 @@
     
-json = client.post('/senseknocker/handle_form', %7B%0A                    
+bug_data = %7B
 'bef
@@ -470,47 +470,152 @@
 n.'%7D
-)%0A        # Once we have a bug tracker,
+%0A        json = client.post('/senseknocker/handle_form', bug_data)%0A%0A        # Check there exists at least one bug with the given characteristics
 %0A   
@@ -625,57 +625,314 @@
   # 
-check that the POST handler actually added a bug.
+in the DB. (There can be more than one, hypothechnically.)%0A        self.assert_(list(senseknocker.Bug.objects.filter(%0A                before=bug_data%5B'before'%5D, %0A                expected_behavior=bug_data%5B'expected_behavior'%5D,%0A                actual_behavior=bug_data%5B'actual_behavior'%5D%0A                )))
 %0A   

Test that we actually create a senseknocker bug.