def test_two_globs_failure(self): with cli_test(self, main) as t: t.args([ '../build/ties_validate_tests/failure1.*', '../build/ties_validate_tests/failure2.*' ]) t.return_code(1) t.stdout_text( _make_status( "Validating {}".format( abspath('../build/ties_validate_tests/failure1.json')), 'ERROR')) t.stderr('Schema validation was unsuccessful:') t.stderr('error:') t.stderr( ' required properties [objectItems, securityTag, version] are missing' ) t.stderr(' location: /') t.stdout_text( _make_status( "Validating {}".format( abspath('../build/ties_validate_tests/failure2.json')), 'ERROR')) t.stderr('Schema validation was unsuccessful:') t.stderr('error:') t.stderr( ' required properties [objectItems, securityTag, version] are missing' ) t.stderr(' location: /')
def test_outfile_fnf(self): with cli_test(self, main) as t: t.args(self._default_args + ['-f', '/dev/full', self._input_file_path]) t.return_code(1) t.stdout_text() t.stderr('error: could not write to file: /dev/full')
def test_stdin_success(self): with cli_test(self, main) as t: t.args(['-']) t.return_code(0) t.stdin(minimal_valid_json) t.stdout_text(_make_status('Validating stdin', 'done')) t.stderr()
def test_inplace_stdin(self): with cli_test(self, main) as t: t.args(self._default_args + ['-i', '-']) t.stdin(test_input) t.return_code(0) t.stdout_json(test_output) t.stderr()
def test_inplace(self): with cli_test(self, main) as t: t.args(self._default_args + ['-i', self._input_file_path]) t.return_code(0) t.stdout_text() t.stderr() self._check_input_file_json(test_output)
def test_stdin_stdout(self): with cli_test(self, main) as t: t.args(['-']) t.stdin(test_input) t.return_code(0) t.stdout_json(test_output) t.stderr()
def test_inplace_write_error(self): os.chmod(self._input_file_path, S_IRUSR) with cli_test(self, main) as t: t.args(self._default_args + ['-i', self._input_file_path]) t.return_code(1) t.stdout_text() t.stderr("error: could not write to file: {}".format( self._input_file_path))
def test_stdin_outfile(self): with cli_test(self, main) as t: t.args(self._default_args + ['-f', self._output_file_path, '-']) t.stdin(test_input) t.return_code(0) t.stdout_text() t.stderr() self._check_output_file_json(test_output)
def test_one_file_success(self): with cli_test(self, main) as t: t.args(['../build/ties_validate_tests/success1.json']) t.return_code(0) t.stdout_text( _make_status( "Validating {}".format( abspath('../build/ties_validate_tests/success1.json')), 'done')) t.stderr()
def test_inplace_outfile_error(self): with cli_test(self, main) as t: t.args(self._default_args + ['-i', '-f', self._output_file_path, self._input_file_path]) t.return_code(2) t.stdout_text() t.stderr(short_usage) t.stderr( 'ties-convert: error: argument --output-file/-f: not allowed with argument --in-place/-i' )
def test_no_args(self): with cli_test(self, main) as t: t.args([]) t.return_code(2) t.stdout_text() t.stderr(short_usage) t.stderr( 'ties-convert: error: the following arguments are required: EXPORT_PATH' ) t.stderr()
def test_stdin_failure(self): with cli_test(self, main) as t: t.args(['-']) t.return_code(1) t.stdin(minimal_invalid_json) t.stdout_text(_make_status('Validating stdin', 'ERROR')) t.stderr('Schema validation was unsuccessful:') t.stderr('error:') t.stderr( ' required properties [objectItems, securityTag, version] are missing' ) t.stderr(' location: /')
def test_glob_fnf(self): with cli_test(self, main) as t: t.args(['../build/ties_validate_tests/fnf*.json']) t.stdout_text( _make_status( "Validating {}".format( abspath('../build/ties_validate_tests/fnf*.json')), 'ERROR')) t.stderr('Schema validation was unsuccessful:') t.stderr('error:') t.stderr("[Errno 2] No such file or directory: '{}'".format( abspath('../build/ties_validate_tests/fnf*.json')))
def test_infile_parse_exception(self): with cli_test(self, main) as t: t.args(self._default_args + ['/dev/null']) t.return_code(1) t.stdout_text() t.stderr('error: could not read from file: /dev/null')
def test_infile_stdout(self): with cli_test(self, main) as t: t.args([self._input_file_path]) t.return_code(0) t.stdout_json(test_output) t.stderr()
def test_stdin_parse_exception(self): with cli_test(self, main) as t: t.args(self._default_args + ['-']) t.return_code(1) t.stdout_text() t.stderr('error: could not parse JSON from stdin')
def test_help_short(self): with cli_test(self, main) as t: t.args(['-h']) t.return_code(0) t.stdout_text(long_usage) t.stderr()
def test_infile_fnf(self): with cli_test(self, main) as t: t.args(self._default_args + ['/file/not/found']) t.return_code(1) t.stdout_text() t.stderr('error: could not read from file: /file/not/found')