Example #1
0
    def test_json_selector(self):
        SEL1_DATA = [["Coast", "100"]]
        SEL2_DATA = [["Plains", "200"]]

        # make sure legacy selectors still work
        with make_input(FILE_JSON_SELECTOR, True, selector="sel1") as input:
            self.assertEqual(SEL1_DATA, hxl.data(input).values)
        with make_input(FILE_JSON_SELECTOR, True, selector="sel2") as input:
            self.assertEqual(SEL2_DATA, hxl.data(input).values)

        # test JSONPath support
        with make_input(FILE_JSON_SELECTOR, True, selector="$.sel1") as input:
            self.assertEqual(SEL1_DATA, hxl.data(input).values)
Example #2
0
 def test_csv_latin1(self):
     with make_input(FILE_CSV_LATIN1, True, encoding="latin1") as input:
         self.assertTrue('#sector' in hxl.data(input).tags)
Example #3
0
 def test_zip_invalid(self):
     """Expect a HXLIOException, not a meaningless TypeError"""
     with self.assertRaises(hxl.input.HXLIOException):
         make_input(FILE_ZIP_INVALID, True)
Example #4
0
 def test_csv_zipped(self):
     with make_input(FILE_ZIP_CSV, True) as input:
         self.assertFalse(input.is_repeatable)
         self.assertTrue('#sector' in hxl.data(input).tags)
Example #5
0
 def test_csv_semicolon_separated(self):
     with make_input(FILE_SSV, True) as input:
         self.assertFalse(input.is_repeatable)
         self.assertTrue('#sector' in hxl.data(input).tags)
Example #6
0
 def test_array(self):
     self.assertTrue(make_input(DATA).is_repeatable)
     self.assertTrue('#sector' in hxl.data(DATA).tags)
Example #7
0
 def test_xlsx_sheet_index(self):
     # a non-existant sheet should throw an exception
     with self.assertRaises(hxl.input.HXLIOException):
         with make_input(FILE_XLSX, True, sheet_index=100) as input:
             pass
Example #8
0
 def test_xlsx(self):
     with make_input(FILE_XLSX, True) as input:
         self.assertTrue(input.is_repeatable)
Example #9
0
 def test_json_objects(self):
     with make_input(FILE_JSON_OBJECTS, True) as input:
         self.assertFalse(input.is_repeatable)
         self.assertTrue('#sector' in hxl.data(input).tags)