Exemplo n.º 1
0
    def test_application_created_signal_on_new(self):
        '''
            When a new application is created the application_created signal should be
            dispatched, and this should send the application in a field called application
        '''

        with mock_signal_receiver(
                application_created) as application_created_receiver:

            a_user = self.test_user
            my_application = EthicsApplication(title='test',
                                               principle_investigator=a_user)
            my_application.save()
            application_created_receiver.assert_called_once_with(
                application=my_application,
                signal=application_created,
                sender=my_application)

            #the signal should not be sent again on an edit:

            my_application.title = 'changed title'
            my_application.save()
            self.assertEqual(
                application_created_receiver.call_count,
                1)  # should only be one as we have not called it again
Exemplo n.º 2
0
    def test_workflow_add_on_new_ethicsapplications(self, patched_function):
        '''
            If this is a new EthicsApplication object then it should be added to the 
            workflow using the _add_to_workflow function, if it is an existing entity then
            the _add_to_wokrflow function should not be called
        
        ''' 

            
        #create a new ethicsapplication object and save it
        a_user = self.test_user
        my_Application = EthicsApplication(title='test', principle_investigator=a_user)
        my_Application.save()
        #assert that it was called once
        patched_function.assert_called_once_with()
        
        #make a change and save, the patch should not be called again!
        my_Application.title = 'changed'
        my_Application.save()
        
        patched_function.assert_called_once_with()
Exemplo n.º 3
0
 def test_application_created_signal_on_new(self):
     '''
         When a new application is created the application_created signal should be
         dispatched, and this should send the application in a field called application
     '''     
     
     with mock_signal_receiver(application_created) as application_created_receiver:
     
         a_user = self.test_user
         my_application = EthicsApplication(title='test', principle_investigator=a_user)
         my_application.save()
         application_created_receiver.assert_called_once_with(application=my_application,
                                                              signal=application_created,
                                                              sender=my_application)
     
     
         #the signal should not be sent again on an edit:
         
         my_application.title = 'changed title'
         my_application.save()
         self.assertEqual(application_created_receiver.call_count, 1)# should only be one as we have not called it again
Exemplo n.º 4
0
    def test_workflow_add_on_new_ethicsapplications(self, patched_function):
        '''
            If this is a new EthicsApplication object then it should be added to the 
            workflow using the _add_to_workflow function, if it is an existing entity then
            the _add_to_wokrflow function should not be called
        
        '''

        #create a new ethicsapplication object and save it
        a_user = self.test_user
        my_Application = EthicsApplication(title='test',
                                           principle_investigator=a_user)
        my_Application.save()
        #assert that it was called once
        patched_function.assert_called_once_with()

        #make a change and save, the patch should not be called again!
        my_Application.title = 'changed'
        my_Application.save()

        patched_function.assert_called_once_with()