File: test_lattice.py

package info (click to toggle)
python-leather 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 652 kB
  • sloc: python: 2,385; makefile: 117; sh: 5
file content (84 lines) | stat: -rw-r--r-- 2,023 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import leather


class TestLattice(leather.LeatherTestCase):
    def setUp(self):
        self.data1 = [
            (0, 3),
            (4, 5),
            (7, 9),
            (8, 4)
        ]

        self.data2 = [
            (0, 4),
            (1, 3),
            (2, 5),
            (5, 6),
            (9, 10)
        ]

    def test_add_one(self):
        lattice = leather.Lattice()
        lattice.add_one(self.data1)
        lattice.add_one(self.data2)

        svg = self.render_chart(lattice)

        self.assertElementCount(svg, '.axis', 4)
        self.assertElementCount(svg, '.series', 2)
        self.assertElementCount(svg, '.lines', 2)

    def test_add_many(self):
        lattice = leather.Lattice()
        lattice.add_many([self.data1, self.data2, self.data1])

        svg = self.render_chart(lattice)

        self.assertElementCount(svg, '.axis', 6)
        self.assertElementCount(svg, '.series', 3)
        self.assertElementCount(svg, '.lines', 3)

    def test_bars(self):
        data1 = [
            (2, 'foo'),
            (6, 'bar'),
            (9, 'bing')
        ]

        data2 = [
            (3, 'foo'),
            (5, 'bar'),
            (7, 'bing')
        ]

        lattice = leather.Lattice(shape=leather.Bars())
        lattice.add_many([data1, data2])

        svg = self.render_chart(lattice)

        self.assertElementCount(svg, '.axis', 4)
        self.assertElementCount(svg, '.series', 2)
        self.assertElementCount(svg, '.bars', 2)

    def test_bars_different(self):
        data1 = [
            (3, 'foo'),
            (5, 'bar'),
            (9, 'bing')
        ]

        data2 = [
            (3, 'foo'),
            (5, 'bar'),
            (9, 'baz')
        ]

        lattice = leather.Lattice(shape=leather.Bars())
        lattice.add_many([data1, data2])

        svg = self.render_chart(lattice)

        self.assertElementCount(svg, '.axis', 4)
        self.assertElementCount(svg, '.series', 2)
        self.assertElementCount(svg, '.bars', 2)