File: test_gauge.py

package info (click to toggle)
python-pygal 3.1.0-0.1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 664 kB
  • sloc: python: 7,385; makefile: 8
file content (35 lines) | stat: -rw-r--r-- 938 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 pygal import Gauge


def test_gauge_reverse_direction():
    """Test that reverse_direction config is respected"""
    gauge = Gauge(reverse_direction=True)
    assert gauge.config.reverse_direction is True

    gauge.add('A', 10)
    gauge.range = (0, 10)
    gauge.setup()

    # When reversed, the polar box should be (0, 1, max, min)
    # min=0, max=10
    # reversed: (0, 1, 10, 0)
    assert gauge._box._tmin == 10
    assert gauge._box._tmax == 0
    assert gauge._box._rmin == 0
    assert gauge._box._rmax == 1

def test_gauge_normal_direction():
    """Test that normal direction works as expected"""
    gauge = Gauge()
    assert gauge.config.reverse_direction is False

    gauge.add('A', 10)
    gauge.range = (0, 10)
    gauge.setup()

    # min=0, max=10
    # normal: (0, 1, 0, 10)
    assert gauge._box._tmin == 0
    assert gauge._box._tmax == 10
    assert gauge._box._rmin == 0
    assert gauge._box._rmax == 1