class StaticfileExtractorTestCase(ExtractorTestCase):
    def setUp(self):
        super(StaticfileExtractorTestCase, self).setUp()
        self.extractor = StaticJSONDumpExtractor(self.source_definition)

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

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

    def test_load_from_gzip(self):
        with gzip.open(self.source_definition.get('dump_path'), 'rb') as f:
            self.assertIsInstance(f, gzip.GzipFile)
            line = f.readline()
            doc = json.loads(line.strip())
            self.assertIsInstance(doc, dict)

    def test_content_type(self):
        content_type, doc = self.extractor.run().next()
        self.assertEqual(content_type, 'application/json')
        # Doc is a serialized JSON document, so a string
        self.assertEqual(type(doc), str)
Пример #2
0
class StaticfileExtractorTestCase(ExtractorTestCase):

    def setUp(self):
        super(StaticfileExtractorTestCase, self).setUp()
        self.extractor = StaticJSONDumpExtractor(self.source_definition)

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

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

    def test_load_from_gzip(self):
        with gzip.open(self.source_definition.get('dump_path'), 'rb') as f:
            self.assertIsInstance(f, gzip.GzipFile)
            line = f.readline()
            doc = json.loads(line.strip())
            self.assertIsInstance(doc, dict)

    def test_content_type(self):
        content_type, doc = self.extractor.run().next()
        self.assertEqual(content_type, 'application/json')
        # Doc is a serialized JSON document, so a string
        self.assertEqual(type(doc), str)
 def setUp(self):
     super(StaticfileExtractorTestCase, self).setUp()
     self.extractor = StaticJSONDumpExtractor(self.source_definition)
 def test_no_dump_path_set(self):
     source_def = self.source_definition
     source_def.pop('dump_path')
     with self.assertRaises(ConfigurationError) as cm:
         StaticJSONDumpExtractor(self.source_definition)
Пример #5
0
 def setUp(self):
     super(StaticfileExtractorTestCase, self).setUp()
     self.extractor = StaticJSONDumpExtractor(self.source_definition)