def test_output_and_overwrite_output(self): with self.assertRaises(UsageError): feed_process_params_from_cli( Settings(), ['output1.json'], None, ['output2.json'], )
def test_feed_export_config_backward_compatible(self): with warnings.catch_warnings(record=True) as cw: settings = Settings() self.assertEqual({'items.dat': { 'format': 'csv' }}, feed_process_params_from_cli(settings, ['items.dat'], 'csv')) self.assertEqual(cw[0].category, ScrapyDeprecationWarning)
def test_feed_export_config_stdout(self): settings = Settings() self.assertEqual( {"stdout:": { "format": "pickle" }}, feed_process_params_from_cli(settings, ["-:pickle"]), )
def test_feed_export_config_overwrite(self): settings = Settings() self.assertEqual( {'output.json': { 'format': 'json', 'overwrite': True }}, feed_process_params_from_cli(settings, [], None, ['output.json']))
def process_options(self, args, opts): ScrapyCommand.process_options(self, args, opts) try: opts.spargs = arglist_to_dict(opts.spargs) except ValueError: raise UsageError("Invalid -a value, use -a NAME=VALUE", print_help=False) if opts.output: feeds = feed_process_params_from_cli(self.settings, opts.output, opts.output_format) self.settings.set('FEEDS', feeds, priority='cmdline')
def test_feed_export_config_backward_compatible(self): with warnings.catch_warnings(record=True) as cw: settings = Settings() self.assertEqual( {"items.dat": { "format": "csv" }}, feed_process_params_from_cli(settings, ["items.dat"], "csv"), ) self.assertEqual(cw[0].category, ScrapyDeprecationWarning)
def test_feed_export_config_implicit_formats(self): settings = Settings() self.assertEqual( { 'items_1.json': { 'format': 'json' }, 'items_2.xml': { 'format': 'xml' }, 'items_3.csv': { 'format': 'csv' } }, feed_process_params_from_cli( settings, ['items_1.json', 'items_2.xml', 'items_3.csv']))
def test_feed_export_config_implicit_formats(self): settings = Settings() self.assertEqual( { "items_1.json": { "format": "json" }, "items_2.xml": { "format": "xml" }, "items_3.csv": { "format": "csv" }, }, feed_process_params_from_cli( settings, ["items_1.json", "items_2.xml", "items_3.csv"]), )
def test_feed_export_config_stdout(self): settings = Settings() self.assertEqual({'stdout:': { 'format': 'pickle' }}, feed_process_params_from_cli(settings, ['-:pickle']))