File: db_web.py

package info (click to toggle)
python-ase 3.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,340 kB
  • sloc: python: 117,348; makefile: 91
file content (35 lines) | stat: -rw-r--r-- 851 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from ase import Atoms
from ase.db import connect
import ase.db.app as app

c = connect('test.db', append=False)
x = [0, 1, 2]
t1 = [1, 2, 0]
t2 = [[2, 3], [1, 1], [1, 0]]

atoms = Atoms('H2O')
atoms.center(vacuum=5)
atoms.set_pbc(True)

c.write(atoms,
        foo=42.0,
        bar='abc',
        data={'x': x,
              't1': t1,
              't2': t2})

c.python = {'title': 'Test title',
            'key_descriptions':
                {'foo': ('FOO', 'FOO ...', '`m_e`')},
            'default_columns': ['foo', 'formula', 'bar']}
app.databases['default'] = c
app.app.testing = True
c = app.app.test_client()
page = c.get('/').data.decode()
assert 'Test title' in page
assert 'FOO' in page
c.get('/default/row/1')
c.get('/default/json/1').data
c.get('/default/sqlite/1').data
c.get('/default/sqlite?x=1').data
c.get('/default/json?x=1').data