Exemplo n.º 1
0
class StaticJSONExtractorTestCase(ExtractorTestCase):
    def setUp(self):
        super(StaticJSONExtractorTestCase, self).setUp()
        self.source_definition['file_url'] = 'http://example.org/dump.json'
        self.extractor = StaticJSONExtractor(self.source_definition)

    def test_dump_path_set(self):
        self.assertIn('file_url', self.source_definition)

    def test_no_dump_path_set(self):
        source_def = self.source_definition
        source_def.pop('file_url')
        with self.assertRaises(ConfigurationError) as cm:
            StaticJSONExtractor(self.source_definition)

    def test_content_type(self):
        # no need to test fetching here, just splitting of items
        content_type, doc = self.extractor.extract_items(
            json.dumps([{'field': 1}])
        ).next()
        self.assertEqual(content_type, 'application/json')
        # Doc is a serialized JSON document, so a string
        self.assertEqual(type(doc), str)
class StaticJSONExtractorTestCase(ExtractorTestCase):
    def setUp(self):
        super(StaticJSONExtractorTestCase, self).setUp()
        self.source_definition['file_url'] = 'http://example.org/dump.json'
        self.extractor = StaticJSONExtractor(self.source_definition)

    def test_dump_path_set(self):
        self.assertIn('file_url', self.source_definition)

    def test_no_dump_path_set(self):
        source_def = self.source_definition
        source_def.pop('file_url')
        with self.assertRaises(ConfigurationError) as cm:
            StaticJSONExtractor(self.source_definition)

    def test_content_type(self):
        # no need to test fetching here, just splitting of items
        content_type, doc = self.extractor.extract_items(
            json.dumps([{
                'field': 1
            }])).next()
        self.assertEqual(content_type, 'application/json')
        # Doc is a serialized JSON document, so a string
        self.assertEqual(type(doc), str)
 def test_no_dump_path_set(self):
     source_def = self.source_definition
     source_def.pop('file_url')
     with self.assertRaises(ConfigurationError) as cm:
         StaticJSONExtractor(self.source_definition)
 def setUp(self):
     super(StaticJSONExtractorTestCase, self).setUp()
     self.source_definition['file_url'] = 'http://example.org/dump.json'
     self.extractor = StaticJSONExtractor(self.source_definition)
Exemplo n.º 5
0
 def setUp(self):
     super(StaticJSONExtractorTestCase, self).setUp()
     self.source_definition['file_url'] = 'http://example.org/dump.json'
     self.extractor = StaticJSONExtractor(self.source_definition)