|
33 | 33 | expect(graph.fields).to(contain_only('potencia')) |
34 | 34 | expect(graph.total_domain).to(be_none) |
35 | 35 | expect(graph.show_percent).to(be_true) |
| 36 | + expect(graph.progressbar).to(be_false) |
36 | 37 | expect(graph.suffix).to(equal('kW')) |
37 | 38 |
|
| 39 | + with it('should support progressbar attribute'): |
| 40 | + xml = """<?xml version="1.0"?> |
| 41 | + <graph string="My indicator" progressbar="1" type="indicator" /> |
| 42 | + """ |
| 43 | + graph = parse_graph(xml) |
| 44 | + expect(graph.progressbar).to(be_true) |
| 45 | + expect(graph.show_percent).to(be_false) |
| 46 | + |
| 47 | + with it('should calculate percent when progressbar is true'): |
| 48 | + xml = """<?xml version="1.0"?> |
| 49 | + <graph string="My indicator" progressbar="1" type="indicator" /> |
| 50 | + """ |
| 51 | + graph = parse_graph(xml) |
| 52 | + result = graph.process(50, 100) |
| 53 | + expect(result).to(have_key('percent', 50.0)) |
| 54 | + expect(result).to(have_key('progressbar', True)) |
| 55 | + expect(result).not_to(have_key('showPercent')) |
| 56 | + |
| 57 | + with it('should calculate percent when showPercent is true'): |
| 58 | + xml = """<?xml version="1.0"?> |
| 59 | + <graph string="My indicator" showPercent="1" type="indicator" /> |
| 60 | + """ |
| 61 | + graph = parse_graph(xml) |
| 62 | + result = graph.process(50, 100) |
| 63 | + expect(result).to(have_key('percent', 50.0)) |
| 64 | + expect(result).to(have_key('showPercent', True)) |
| 65 | + |
| 66 | + with it('should not include percent when both progressbar and showPercent are false'): |
| 67 | + xml = """<?xml version="1.0"?> |
| 68 | + <graph string="My indicator" type="indicator" /> |
| 69 | + """ |
| 70 | + graph = parse_graph(xml) |
| 71 | + result = graph.process(50, 100) |
| 72 | + expect(result).not_to(have_key('percent')) |
| 73 | + expect(result).not_to(have_key('progressbar')) |
| 74 | + expect(result).not_to(have_key('showPercent')) |
| 75 | + |
38 | 76 | with it("should parse a chart graph XML with type line"): |
39 | 77 | xml = """<?xml version="1.0"?> |
40 | 78 | <graph type="line" y_range="auto"> |
|
0 commit comments