1 from datasette.app import Datasette
6 def app_client(max_returned_rows=None):
7 with tempfile.TemporaryDirectory() as tmpdir:
8 filepath = os.path.join(tmpdir, 'test_tables.h5')
9 populate_file(filepath)
13 'default_page_size': 50,
14 'max_returned_rows': max_returned_rows or 100,
17 client = ds.app().test_client
21 def populate_file(filepath):
22 class Particle(IsDescription):
23 identity = StringCol(itemsize=22, dflt=' ', pos=0)
24 idnumber = Int16Col(dflt=1, pos=1)
25 speed = Float32Col(dflt=1, pos=2)
27 h5file = open_file(filepath, mode='w')
30 group1 = h5file.create_group(root, 'group1')
31 group2 = h5file.create_group(root, 'group2')
33 array1 = h5file.create_array(root, 'array1', ['string', 'array'])
35 table1 = h5file.create_table(group1, 'table1', Particle)
36 table2 = h5file.create_table(group2, 'table2', Particle)
38 array2 = h5file.create_array(group1, 'array2', [x for x in range(10000)])
40 for table in (table1, table2):
43 for i in range(10000):
44 row['identity'] = 'This is particle: %2d' % (i)