Exemplo n.º 1
0
    def test_invalid_config_file(self):
        config_path = sample_config_path('missing_meuhconfig_var.py')
        args = _str_to_args("./meuh {config} {dwca}".format(config=config_path,
                                                            dwca=self.SAMPLE_ARCHIVE_PATH))
        err_stream = StringIO()
        out_stream = StringIO()

        with self.assertRaises(BadConfigFileException):
            main(args, out=out_stream, err=err_stream)
Exemplo n.º 2
0
    def test_default_format_json(self):
        """Ensure that JSON is the default report format"""

        err_stream = StringIO()
        out_stream = StringIO()

        config_file = sample_config_path('valid.py')

        # Provide both
        args = _str_to_args("./meuh {config} {dwca}".format(config=config_file,
                            dwca=self.SAMPLE_ARCHIVE_PATH))
        main(args, out=out_stream, err=err_stream)
        
        json.loads(out_stream.getvalue())  # Will raise ValueError if cannot parse JSON
Exemplo n.º 3
0
    def test_output_format_json(self):
        """Ensure that json is produced when asked."""
        # TODO: Make similar tests with other formats
        err_stream = StringIO()
        out_stream = StringIO()

        config_file = sample_config_path('valid.py')

        # Provide both
        args = _str_to_args("./meuh --report-format json {config} {dwca}".format(config=config_file,
                            dwca=self.SAMPLE_ARCHIVE_PATH))
        main(args, out=out_stream, err=err_stream)
        
        json.loads(out_stream.getvalue())  # Will raise ValueError if cannot parse JSON
Exemplo n.º 4
0
    def test_minimal_args_correct(self):
        """Check that argument parsing succeed if we get two readable files."""

        err_stream = StringIO()
        out_stream = StringIO()

        config_file = sample_config_path('valid.py')

        # Provide both
        args = _str_to_args("./meuh {config} {dwca}".format(config=config_file,
                                                            dwca=self.SAMPLE_ARCHIVE_PATH))
        rc = main(args, out=out_stream, err=err_stream)
        
        self.assertTrue("usage: meuh" not in err_stream.getvalue())
        self.assertEqual(0, rc)
Exemplo n.º 5
0
    def test_engine_output_stderr(self):
        err_stream = StringIO()
        out_stream = StringIO()

        config_file = sample_config_path('valid.py')

        # Provide both
        args = _str_to_args("./meuh {config} {dwca}".format(config=config_file,
                                                            dwca=self.SAMPLE_ARCHIVE_PATH))
        main(args, out=out_stream, err=err_stream)

        err = err_stream.getvalue()
        out = out_stream.getvalue()

        self.assertTrue("Engine running..." in err)
        self.assertTrue("Engine finished execution." in err)
        self.assertFalse("Engine running..." in out)
        self.assertFalse("Engine finished execution." in out)
Exemplo n.º 6
0
    def test_report_on_stdout(self):
        """Ensure the report is printed on stdout and not on stderr."""
        err_stream = StringIO()
        out_stream = StringIO()

        config_file = sample_config_path('valid.py')

        # Provide both
        args = _str_to_args("./meuh --report-format json {config} {dwca}".format(config=config_file,
                            dwca=self.SAMPLE_ARCHIVE_PATH))
        main(args, out=out_stream, err=err_stream)

        err = err_stream.getvalue()
        out = out_stream.getvalue()

        report_excerpt = '{"context": {"execution_started_at":'

        self.assertTrue(report_excerpt in out)
        self.assertFalse(report_excerpt in err)