def test_is_ready_to_submit(self): ''' This test should only return true is there is an answerset available for the checklist and every questiongroup in the applicationform. ''' with patch('ethicsapplication.models.EthicsApplication.get_answersets') as get_answersets_mock: answerset_mock = MagicMock(name='answerset') answerset_mock.is_complete.return_value = True answer_set_dict = MagicMock(name='answerset_dict') answer_set_dict.__getitem__.return_value = answerset_mock answer_set_dict.__contains__.return_value = True get_answersets_mock.return_value = answer_set_dict #checklist & applciation form incomplete self._fabricate_checklist(self.ethics_application) self._fabricate_application_form(self.ethics_application) self.assertTrue(self.ethics_application.is_ready_to_submit()) answer_set_dict.__contains__.assert_any_call(self.ethics_application.checklist.get_ordered_groups()[0]) answer_set_dict.__contains__.assert_any_call(self.ethics_application.application_form.get_ordered_groups()[0]) answer_set_dict.__getitem__.assert_any_call(self.ethics_application.checklist.get_ordered_groups()[0]) answer_set_dict.__getitem__.assert_any_call(self.ethics_application.application_form.get_ordered_groups()[0]) self.assertEqual(get_answersets_mock.call_count , 1) self.assertEqual(answerset_mock.mock_calls, [call.is_complete(), call.is_complete()])
def test_is_ready_to_submit_answer_sets_incomplete(self): ''' ''' with patch('ethicsapplication.models.EthicsApplication.get_answersets') as get_answersets_mock: answerset_mock = MagicMock(name='answerset') answerset_mock.is_complete.return_value = False answer_set_dict = MagicMock(name='answerset_dict') answer_set_dict.__getitem__.return_value = answerset_mock answer_set_dict.__contains__.return_value = True get_answersets_mock.return_value = answer_set_dict #checklist & applciation form incomplete self._fabricate_checklist(self.ethics_application) self._fabricate_application_form(self.ethics_application) self.assertFalse(self.ethics_application.is_ready_to_submit()) self.assertEqual(answer_set_dict.__contains__.call_count, 1) self.assertEqual(answer_set_dict.__getitem__.call_count, 1) self.assertEqual(get_answersets_mock.call_count , 1) self.assertEqual(answerset_mock.mock_calls, [call.is_complete()])
def test_is_ready_to_submit_answer_sets_incomplete(self): ''' ''' with patch('ethicsapplication.models.EthicsApplication.get_answersets' ) as get_answersets_mock: answerset_mock = MagicMock(name='answerset') answerset_mock.is_complete.return_value = False answer_set_dict = MagicMock(name='answerset_dict') answer_set_dict.__getitem__.return_value = answerset_mock answer_set_dict.__contains__.return_value = True get_answersets_mock.return_value = answer_set_dict #checklist & applciation form incomplete self._fabricate_checklist(self.ethics_application) self._fabricate_application_form(self.ethics_application) self.assertFalse(self.ethics_application.is_ready_to_submit()) self.assertEqual(answer_set_dict.__contains__.call_count, 1) self.assertEqual(answer_set_dict.__getitem__.call_count, 1) self.assertEqual(get_answersets_mock.call_count, 1) self.assertEqual(answerset_mock.mock_calls, [call.is_complete()])
def test_is_ready_to_submit(self): ''' This test should only return true is there is an answerset available for the checklist and every questiongroup in the applicationform. ''' with patch('ethicsapplication.models.EthicsApplication.get_answersets' ) as get_answersets_mock: answerset_mock = MagicMock(name='answerset') answerset_mock.is_complete.return_value = True answer_set_dict = MagicMock(name='answerset_dict') answer_set_dict.__getitem__.return_value = answerset_mock answer_set_dict.__contains__.return_value = True get_answersets_mock.return_value = answer_set_dict #checklist & applciation form incomplete self._fabricate_checklist(self.ethics_application) self._fabricate_application_form(self.ethics_application) self.assertTrue(self.ethics_application.is_ready_to_submit()) answer_set_dict.__contains__.assert_any_call( self.ethics_application.checklist.get_ordered_groups()[0]) answer_set_dict.__contains__.assert_any_call( self.ethics_application.application_form.get_ordered_groups() [0]) answer_set_dict.__getitem__.assert_any_call( self.ethics_application.checklist.get_ordered_groups()[0]) answer_set_dict.__getitem__.assert_any_call( self.ethics_application.application_form.get_ordered_groups() [0]) self.assertEqual(get_answersets_mock.call_count, 1) self.assertEqual( answerset_mock.mock_calls, [call.is_complete(), call.is_complete()])