def test_writes_file_header_to_table(self):
        temp_fs = fsopendir("temp://")
        parent = MagicMock()
        writer = HDFWriter(parent, temp_fs.getsyspath("temp.h5"))
        writer._validate_groups()
        writer.n_rows = 2
        writer.n_cols = 3
        writer.write_file_header()

        self.assertIn("file_header", writer._h5_file.root.partition)
        table = writer._h5_file.root.partition.file_header
        self.assertEqual([(x["version"], x["n_rows"], x["n_cols"]) for x in table.iterrows()], [(1, 2, 3)])
Example #2
0
    def test_writes_file_header_to_table(self):
        temp_fs = fsopendir('temp://')
        parent = MagicMock()
        writer = HDFWriter(parent, temp_fs.getsyspath('temp.h5'))
        writer._validate_groups()
        writer.n_rows = 2
        writer.n_cols = 3
        writer.write_file_header()

        self.assertIn('file_header', writer._h5_file.root.partition)
        table = writer._h5_file.root.partition.file_header
        self.assertEqual([(x['version'], x['n_rows'], x['n_cols'])
                          for x in table.iterrows()], [(1, 2, 3)])
    def test_saves_hist_and_uvalues_as_json_string(self):
        temp_fs = fsopendir("temp://")
        parent = MagicMock()
        writer = HDFWriter(parent, temp_fs.getsyspath("temp.h5"))
        writer._validate_groups()
        writer.meta["schema"].append(
            self._get_column("col1", "str", predefined={"hist": [1, 2, 3], "uvalues": ["1", "2", "3"]})
        )
        writer._save_schema()

        self.assertEqual(
            [(x["hist"], x["uvalues"]) for x in writer._h5_file.root.partition.meta.schema.iterrows()],
            [(b("[1, 2, 3]"), b('["1", "2", "3"]'))],
        )
Example #4
0
    def test_saves_hist_and_uvalues_as_json_string(self):
        temp_fs = fsopendir('temp://')
        parent = MagicMock()
        writer = HDFWriter(parent, temp_fs.getsyspath('temp.h5'))
        writer._validate_groups()
        writer.meta['schema'].append(
            self._get_column('col1',
                             'str',
                             predefined={
                                 'hist': [1, 2, 3],
                                 'uvalues': ['1', '2', '3']
                             }))
        writer._save_schema()

        self.assertEqual(
            [(x['hist'], x['uvalues'])
             for x in writer._h5_file.root.partition.meta.schema.iterrows()],
            [(b('[1, 2, 3]'), b('["1", "2", "3"]'))])
    def test_saves_header_rows_and_comment_rows_as_json_string(self):
        temp_fs = fsopendir("temp://")
        parent = MagicMock()
        writer = HDFWriter(parent, temp_fs.getsyspath("temp.h5"))
        writer._validate_groups()
        writer.meta["row_spec"]["comment_rows"] = [0, 1]
        writer.meta["row_spec"]["header_rows"] = [2, 3]
        descriptor = {
            "end_row": Int32Col(),
            "header_rows": StringCol(itemsize=255),
            "start_row": Int32Col(),
            "comment_rows": StringCol(itemsize=255),
            "data_pattern": StringCol(itemsize=255),
        }
        writer._save_meta_child("row_spec", descriptor)

        self.assertEqual(
            [(x["comment_rows"], x["header_rows"]) for x in writer._h5_file.root.partition.meta.row_spec.iterrows()],
            [(b("[0, 1]"), b("[2, 3]"))],
        )
Example #6
0
    def test_saves_header_rows_and_comment_rows_as_json_string(self):
        temp_fs = fsopendir('temp://')
        parent = MagicMock()
        writer = HDFWriter(parent, temp_fs.getsyspath('temp.h5'))
        writer._validate_groups()
        writer.meta['row_spec']['comment_rows'] = [0, 1]
        writer.meta['row_spec']['header_rows'] = [2, 3]
        descriptor = {
            'end_row': Int32Col(),
            'header_rows': StringCol(itemsize=255),
            'start_row': Int32Col(),
            'comment_rows': StringCol(itemsize=255),
            'data_pattern': StringCol(itemsize=255)
        }
        writer._save_meta_child('row_spec', descriptor)

        self.assertEqual(
            [(x['comment_rows'], x['header_rows'])
             for x in writer._h5_file.root.partition.meta.row_spec.iterrows()],
            [(b('[0, 1]'), b('[2, 3]'))])