예제 #1
0
 def test_contact_form_is_valid_sends(self):
     """when the contact form is valid the valid signal is sent"""
     # our test dict confirms that the signal not sent
     global testdict
     self.assertEqual(testdict['signal_sent'], False)
     # test listener
     def test_listener(**kwargs):
         global testdict
         testdict['signal_sent'] = True
     # connect it
     contact_form_is_valid.connect(
             test_listener,
             dispatch_uid='test_contact_form_is_valid_sends')
     # now get the response
     response = contact(self.request)
     # test dict has been updated
     self.assertEqual(testdict['signal_sent'], True)
예제 #2
0
 def test_sends_correct_arguments(self):
     """"test that the view passes the signal the correct args"""
     global testdict
     # the listener
     def test_listener(sender, request, form, **kwargs):
         global testdict
         testdict['request'] = request
         testdict['form'] = form
     # connect it
     contact_form_is_valid.connect(
             test_listener,
             dispatch_uid='test_sends_correct_arguments')
     # now get the response
     response = contact(self.request)
     # test dict has been updated
     self.assertTrue(testdict['request'], True)
     self.assertTrue(testdict['form'], True)