1 from datasette.app import Datasette
7 def app_client(max_returned_rows=None):
8 with tempfile.TemporaryDirectory() as tmpdir:
9 filepath = os.path.join(tmpdir, 'test_tables.h5')
10 populate_file(filepath)
14 'default_page_size': 50,
15 'max_returned_rows': max_returned_rows or 1000,
18 client = ds.app().test_client
22 def populate_file(filepath):
23 class Particle(IsDescription):
24 identity = StringCol(itemsize=22, dflt=' ', pos=0)
25 idnumber = Int16Col(dflt=1, pos=1)
26 speed = Float32Col(dflt=1, pos=2)
28 h5file = open_file(filepath, mode='w')
31 group1 = h5file.create_group(root, 'group1')
32 group2 = h5file.create_group(root, 'group2')
34 array1 = h5file.create_array(root, 'array1', ['string', 'array'])
36 table1 = h5file.create_table(group1, 'table1', Particle)
37 table2 = h5file.create_table(group2, 'table2', Particle)
39 array2 = h5file.create_array(group1, 'array2', [x for x in range(10000)])
41 multiarray = h5file.create_array(group2, 'multi', np.arange(1000).reshape(10, 50, 2))
43 for table in (table1, table2):
46 for i in range(10000):
47 row['identity'] = 'This is particle: %2d' % (i)