Exemple #1
0
    def test_get_row(self):

        with self.drtb_import(IMPORT_ROWS, "mumbai") as (csv_file, csv_rows):
            output = DRTBImportHistoryCommand.handle_get_row("some bad id", csv_file)
            csv_file.seek(0)
            self.assertEqual(output, "case not found\n")

            row_case_ids = csv_rows[0]['case_ids'].split(",")
            for case_id in row_case_ids:
                output = DRTBImportHistoryCommand.handle_get_row(case_id, csv_file)
                csv_file.seek(0)
                self.assertEqual(output, "row: 2\n")
Exemple #2
0
    def test_get_outcome(self):
        with self.drtb_import(IMPORT_ROWS, "mumbai") as (csv_file, csv_rows):
            output = DRTBImportHistoryCommand.handle_get_outcome("2", csv_file)
            csv_file.seek(0)

            # Confirm that the outcome contains all the expected case ids
            self.assertNotIn(
                "Traceback", output,
                "Expected list of case ids, but output was: {}".format(output))
            self.assertEqual(len(output.split()), 5 + len(DRUG_MAP))

            output = DRTBImportHistoryCommand.handle_get_outcome("3", csv_file)
            csv_file.seek(0)

            # Confirm that the outcome contains the exception raised for the row
            self.assertTrue("person_name is required" in output)