コード例 #1
0
    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'))
コード例 #2
0
    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)
コード例 #3
0
    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, '')
コード例 #4
0
    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)