|
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.show_total).to(be_true) |
36 | 37 | expect(graph.progressbar).to(be_false) |
37 | 38 | expect(graph.suffix).to(equal('kW')) |
38 | 39 |
|
|
73 | 74 | expect(result).not_to(have_key('progressbar')) |
74 | 75 | expect(result).not_to(have_key('showPercent')) |
75 | 76 |
|
| 77 | + with it('should include showTotal by default'): |
| 78 | + xml = """<?xml version="1.0"?> |
| 79 | + <graph string="My indicator" type="indicator" /> |
| 80 | + """ |
| 81 | + graph = parse_graph(xml) |
| 82 | + expect(graph.show_total).to(be_true) |
| 83 | + result = graph.process(50, 100) |
| 84 | + expect(result).to(have_key('showTotal', True)) |
| 85 | + |
| 86 | + with it('should support showTotal="0" to disable'): |
| 87 | + xml = """<?xml version="1.0"?> |
| 88 | + <graph string="My indicator" showTotal="0" type="indicator" /> |
| 89 | + """ |
| 90 | + graph = parse_graph(xml) |
| 91 | + expect(graph.show_total).to(be_false) |
| 92 | + result = graph.process(50, 100) |
| 93 | + expect(result).to(have_key('showTotal', False)) |
| 94 | + |
| 95 | + with it('should support showTotal="1" explicitly'): |
| 96 | + xml = """<?xml version="1.0"?> |
| 97 | + <graph string="My indicator" showTotal="1" type="indicator" /> |
| 98 | + """ |
| 99 | + graph = parse_graph(xml) |
| 100 | + expect(graph.show_total).to(be_true) |
| 101 | + result = graph.process(50, 100) |
| 102 | + expect(result).to(have_key('showTotal', True)) |
| 103 | + |
| 104 | + with it('should always include showTotal in response'): |
| 105 | + xml = """<?xml version="1.0"?> |
| 106 | + <graph string="My indicator" type="indicator" /> |
| 107 | + """ |
| 108 | + graph = parse_graph(xml) |
| 109 | + result = graph.process(50, 100) |
| 110 | + expect(result).to(have_key('showTotal')) |
| 111 | + expect(result['showTotal']).to(be_true) |
| 112 | + |
| 113 | + xml_false = """<?xml version="1.0"?> |
| 114 | + <graph string="My indicator" showTotal="0" type="indicator" /> |
| 115 | + """ |
| 116 | + graph_false = parse_graph(xml_false) |
| 117 | + result_false = graph_false.process(50, 100) |
| 118 | + expect(result_false).to(have_key('showTotal')) |
| 119 | + expect(result_false['showTotal']).to(be_false) |
| 120 | + |
76 | 121 | with it("should parse a chart graph XML with type line"): |
77 | 122 | xml = """<?xml version="1.0"?> |
78 | 123 | <graph type="line" y_range="auto"> |
|
0 commit comments