File: test_dbservice.py

package info (click to toggle)
python-skytools 3.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 620 kB
  • sloc: python: 6,394; ansic: 929; makefile: 38; awk: 14
file content (14 lines) | stat: -rw-r--r-- 561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14

from skytools.dbservice import transform_fields


def test_transform_fields() -> None:
    rows = []
    rows.append({'time': '22:00', 'metric': 'count', 'value': 100})
    rows.append({'time': '22:00', 'metric': 'dur', 'value': 7})
    rows.append({'time': '23:00', 'metric': 'count', 'value': 200})
    rows.append({'time': '23:00', 'metric': 'dur', 'value': 5})
    res = list(transform_fields(rows, ['time'], 'metric', 'value'))
    assert res[0] == {'count': 100, 'dur': 7, 'time': '22:00'}
    assert res[1] == {'count': 200, 'dur': 5, 'time': '23:00'}