def test_switch_fields(self): self.optional.extend( ['--fields', fixtureToAbsolute('fields-good.txt')]) argv = build_argv(self.optional, self.positional) with captured_output(argv) as (out, err): sut.main() validate_json(self.actual_file, fixtureToAbsolute('utf-8-switched.json'))
def test_json(self): argv = build_argv(self.optional, self.positional) with captured_output(argv) as (out, err): sut.main() validate_json(self.actual_file, fixtureToAbsolute('utf-8.json')) actual_print = out.getvalue().strip() self.assertEqual('2 rows processed', actual_print)
def test_main_happy_path(self): argv = build_argv(positional=self.positional) with captured_output(argv) as (out, err): sut.main() validate_json(self.actual_file, fixtureToAbsolute( 'metadata_public.json')) console_output = out.getvalue() self.assertEqual(console_output, '')
def test_switch_fields_too_many(self): self.optional.extend( ['--fields', fixtureToAbsolute('fields-bad.txt')] ) argv = build_argv(self.optional, self.positional) with captured_output(argv) as (out, err): sut.main() # Still processes! validate_json(self.actual_file, fixtureToAbsolute('utf-8.json')) actual_print = err.getvalue().strip() self.assertIn('has 4 fields. Expected 3', actual_print)