Esempio n. 1
0
    def test_create_(self):
        # filename should contain ENVRIONMENT
        csv_file = datawarehouse.create_kto_feedback_csv(self.csv_tmp_dir)
        self.assertEqual(
            os.path.join(self.csv_tmp_dir, 'kto-feedback-PRODUCTION.csv'),
            csv_file)

        # header and one entry should show up in written file.
        with open(csv_file, 'r') as f:
            reader = csv.DictReader(f)

            i = None
            for i, row in enumerate(reader):
                self.assertEqual(row['_signal_id'],
                                 str(self.feedback_submitted._signal.id))
                self.assertEqual(row['is_satisfied'],
                                 str(self.feedback_submitted.is_satisfied))
                self.assertEqual(row['allows_contact'],
                                 str(self.feedback_submitted.allows_contact))
                self.assertEqual(row['text_extra'],
                                 self.feedback_submitted.text_extra)

                # noqa Disabled because the Postgres format is slightly different than the Python format, so we decided to comment these checks for now
                # self.assertEqual(row['created_at'], str(self.feedback_submitted.created_at))
                # self.assertEqual(row['submitted_at'], str(self.feedback_submitted.submitted_at))

                self.assertEqual(row['text'], self.feedback_submitted.text)

            self.assertEqual(i, 0)
Esempio n. 2
0
    def test_environment_set(self):
        # filename should contain ENVRIONMENT
        file_name = datawarehouse.create_kto_feedback_csv(self.csv_tmp_dir)
        self.assertEqual(os.path.split(file_name)[-1], 'kto-feedback-PRODUCTION.csv')

        # header and one entry should show up in written file.
        with open(file_name, 'r') as f:
            reader = csv.reader(f)

            self.assertEqual(len(list(reader)), 2)
Esempio n. 3
0
 def test_environment_empty(self):
     with self.assertRaises(EnvironmentError):
         datawarehouse.create_kto_feedback_csv('dummy_location')