def test_dispatch_done(self):
     with TempDirectory() as input_dir, TempDirectory() as output_dir:
         mock_module.my_exception_string = ""
         jacquard._dispatch([mock_module], ["mock_module",
                                            input_dir.path,
                                            output_dir.path])
         actual_messages = self.output.getvalue().rstrip().split("\n")
         self.assertRegexpMatches(actual_messages[-1], "Done")
 def test_dispatch(self):
     with TempDirectory() as input_dir, TempDirectory() as output_dir:
         mock_module.my_exception_string = ""
         jacquard._dispatch([mock_module], ["mock_module",
                                            input_dir.path,
                                            output_dir.path])
         self.assertTrue(mock_module.execute_called)
         self.assertTrue(mock_module.report_called)
         self.assertTrue(MOCK_MOVE_TEMP_CONTENTS_CALLED)
Beispiel #3
0
 def test_dispatch(self):
     with TempDirectory() as input_dir, TempDirectory() as output_dir:
         mock_module.my_exception_string = ""
         jacquard._dispatch([mock_module], ["mock_module",
                                            input_dir.path,
                                            output_dir.path])
         self.assertTrue(mock_module.execute_called)
         self.assertTrue(mock_module.report_called)
         self.assertTrue(MOCK_MOVE_TEMP_CONTENTS_CALLED)
 def test_dispatch_doneWithWarnings(self):
     with TempDirectory() as input_dir, TempDirectory() as output_dir:
         mock_module.my_exception_string = ""
         logger.WARNING_OCCURRED = True
         jacquard._dispatch([mock_module], ["mock_module",
                                            input_dir.path,
                                            output_dir.path])
         actual_messages = self.output.getvalue().rstrip().split("\n")
         self.assertRegexpMatches(actual_messages[-1], r"Done. \(See warnings above\)")
         logger.WARNING_OCCURRED = False
 def test_dispatch_unknownCommand(self):
     with TempDirectory() as input_dir, TempDirectory() as output_dir:
         mock_module.my_exception_string = ""
         with self.assertRaises(SystemExit) as exit_code:
             jacquard._dispatch([mock_module], ["foo_command",
                                                input_dir.path,
                                                output_dir.path])
         self.assertEquals(1, exit_code.exception.code)
         self.assertRegexpMatches(self.output.getvalue(),
                                  r"'foo_command' is not a Jacquard command; choose from 'mock_module'")
    def test_dispatch_forceNonEmptyOutputDir(self):
        with TempDirectory() as input_dir, TempDirectory() as output_dir:
            output_dir.write("file1.vcf", b"foo")
            mock_module.my_exception_string = ""

            jacquard._dispatch([mock_module], ["mock_module",
                                               input_dir.path,
                                               output_dir.path,
                                               "--force"])

            self.assertTrue(1 == 1, "Force does not result in premature exit.")
    def test_dispatch_nonEmptyOutputDir(self):
        with TempDirectory() as input_dir, TempDirectory() as output_dir:
            output_dir.write("file1.vcf", b"foo")
            output_file = os.path.join(output_dir.path, "file1.vcf")
            mock_module.my_exception_string = ""
            mock_module.predicted_output = set(["file1.vcf"])
            with self.assertRaises(SystemExit) as exit_code:
                jacquard._dispatch([mock_module], ["mock_module",
                                                   input_dir.path,
                                                   output_file])

            self.assertEqual(1, exit_code.exception.code)
    def test_gracefulErrorMessageWhenUnanticipatedProblem(self):
        with TempDirectory() as input_dir, TempDirectory() as output_dir:
            mock_module.my_exception_string = "I'm feeling angry"

            with self.assertRaises(SystemExit) as exit_code:
                jacquard._dispatch([mock_module], ["mock_module",
                                                   input_dir.path,
                                                   output_dir.path])
            self.assertEqual(1, exit_code.exception.code)

            actual_messages = self.output.getvalue().rstrip().split("\n")

            self.assertEquals(2, len(actual_messages))
            self.assertRegexpMatches(actual_messages[0], "I'm feeling angry")
            self.assertRegexpMatches(actual_messages[1], "Jacquard encountered an unanticipated problem.")
    def assertCommand(self, command, expected_output_path):
        jacquard._dispatch(jacquard._SUBCOMMANDS, command)

        actual_output_path = command[2]

        try:
            if os.path.isfile(actual_output_path):
                self._compare_files(actual_output_path, expected_output_path)
            elif os.path.isdir(actual_output_path):
                for output_filename in os.listdir(actual_output_path):
                    actual_output_file = os.path.join(actual_output_path,
                                                      output_filename)
                    expected_output_file = os.path.join(expected_output_path,
                                                        output_filename)
                    self._compare_files(actual_output_file,
                                        expected_output_file)
        except self.failureException as e:
            msg = "discrepancy in command [{}]: {}".format(" ".join(command), e)
            raise self.failureException(msg)