Ejemplo n.º 1
0
 def test_should_import_next_value_if_exception_with_previous(self):
     organization = Mock(spec=Organization)
     with patch("datawinners.utils.get_organization_from_manager") as get_organization_from_dbm_mock:
         get_organization_from_dbm_mock.return_value = Mock(return_value=organization)
         responses = self.file_player.accept(self.csv_data_with_exception)
     self.assertTrue(responses[0].success)
     self.assertFalse(responses[1].success)
     self.assertTrue(responses[2].success)
     submission_log = Submission.get(self.manager, responses[0].submission_id)
     self.assertDictContainsSubset({'t':'reporter', 'n':'Dr. A','l':'Pune','d':'Description','m':'201'}, submission_log.values)
     self.assertEquals({'error':{'m': u'Sorry, the telephone number 201 has already been registered'}, 'row':{'t':u'reporter', 'n':u'Dr. B','l':[u'arantany'],'d':u'Description','m':u'201','s':u'rep3'}}, responses[1].errors)
     submission_log = Submission.get(self.manager, responses[2].submission_id)
     self.assertDictContainsSubset({'t':'reporter', 'n':'Dr. C','l':'Pune','d':'Description','m':'202'}, submission_log.values)
Ejemplo n.º 2
0
 def test_should_import_csv_string_if_it_contains_data_for_activity_reporters(self):
     organization = Mock(spec=Organization)
     with patch("datawinners.utils.get_organization_from_manager") as get_organization_from_dbm_mock:
         get_organization_from_dbm_mock.return_value = Mock(return_value=organization)
         responses = self.file_player.accept(self.csv_data_for_activity_report)
     self.assertTrue(responses[0].success)
     submission_log = Submission.get(self.manager, responses[0].submission_id)
     self.assertEquals("csv", submission_log.channel)
     self.assertEquals(u'rep1', responses[0].short_code)
Ejemplo n.º 3
0
 def test_should_import_csv_string_if_it_contains_data_about_reporters(self):
     organization = Mock(spec=Organization)
     with patch("datawinners.utils.get_organization_from_manager") as get_organization_from_dbm_mock:
         get_organization_from_dbm_mock.return_value = Mock(return_value=organization)
         responses = self.file_player.accept(self.csv_data_about_reporter)
     self.assertTrue(responses[0].success)
     submission_log = Submission.get(self.manager, responses[0].submission_id)
     self.assertEquals(True, submission_log. status)
     self.assertEquals("csv", submission_log.channel)
     self.assertEquals("reg", submission_log.form_code)
     self.assertDictContainsSubset({'t':'reporter', 'n':'Dr. A','l':'Pune','d':'Description','m':'201'}, submission_log.values)