1 from datasette_connectors import monkey; monkey.patch_datasette()
2 from datasette_connectors.connectors import ConnectorList
3 from datasette_pytables import PyTablesConnector
4 ConnectorList.add_connector('pytables', PyTablesConnector)
6 from datasette.app import Datasette
7 from datasette.utils.testing import TestClient
16 def populate_file(filepath):
17 class Particle(IsDescription):
18 identity = StringCol(itemsize=22, dflt=' ', pos=0)
19 idnumber = Int16Col(dflt=1, pos=1)
20 speed = Float32Col(dflt=1, pos=2)
22 h5file = open_file(filepath, mode='w')
25 group1 = h5file.create_group(root, 'group1')
26 group2 = h5file.create_group(root, 'group2')
28 array1 = h5file.create_array(root, 'array1', ['string', 'array'])
30 table1 = h5file.create_table(group1, 'table1', Particle)
31 table2 = h5file.create_table(group2, 'table2', Particle)
33 array2 = h5file.create_array(group1, 'array2', [x for x in range(10000)])
35 multiarray = h5file.create_array(group2, 'multi', np.arange(1000).reshape(10, 50, 2))
37 for table in (table1, table2):
40 for i in range(10000):
41 row['identity'] = 'This is particle: %2d' % (i)
51 @contextlib.contextmanager
53 max_returned_rows=None,
57 with tempfile.TemporaryDirectory() as tmpdir:
58 filepath = os.path.join(tmpdir, 'test_tables.h5')
59 populate_file(filepath)
62 immutables = [filepath]
68 'default_page_size': 50,
69 'max_returned_rows': max_returned_rows or 1000,
73 immutables=immutables,
76 client = TestClient(ds.app())
81 @pytest.fixture(scope='session')
83 with make_app_client() as client:
87 @pytest.fixture(scope='session')
88 def app_client_with_hash():
89 with make_app_client(config={"hash_urls": True}, is_immutable=True) as client: