File: test_table.py

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (27 lines) | stat: -rw-r--r-- 729 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
from ase.db.table import Table
from types import SimpleNamespace


class TestConnection:
    def select(self,
               query,
               verbosity,
               limit,
               offset,
               sort,
               include_data,
               columns):
        return [SimpleNamespace(id=1, a='hello'),
                SimpleNamespace(id=2, a='hi!!!', b=117)]


def test_hide_empty_columns():
    db = TestConnection()
    table = Table(db)
    for show in [True, False]:
        table.select('...', ['a', 'b', 'c'], '', 10, 0,
                     show_empty_columns=show)
        if show:
            assert table.columns == ['a', 'b', 'c']
        else:
            assert table.columns == ['a', 'b']