|
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 | + expect(graph.show_total).to(be_false) # False because no totalDomain |
37 | 37 | expect(graph.progressbar).to(be_false) |
38 | 38 | expect(graph.suffix).to(equal('kW')) |
39 | 39 |
|
|
74 | 74 | expect(result).not_to(have_key('progressbar')) |
75 | 75 | expect(result).not_to(have_key('showPercent')) |
76 | 76 |
|
77 | | - with it('should include showTotal by default'): |
| 77 | + with it('should not include showTotal by default when no totalDomain'): |
78 | 78 | xml = """<?xml version="1.0"?> |
79 | 79 | <graph string="My indicator" type="indicator" /> |
80 | 80 | """ |
81 | 81 | graph = parse_graph(xml) |
| 82 | + expect(graph.show_total).to(be_false) |
| 83 | + result = graph.process(50, 100) |
| 84 | + expect(result).to(have_key('showTotal', False)) |
| 85 | + |
| 86 | + with it('should include showTotal=True by default when totalDomain is defined'): |
| 87 | + xml = """<?xml version="1.0"?> |
| 88 | + <graph string="My indicator" type="indicator" totalDomain="[('user', '=', uid)]" /> |
| 89 | + """ |
| 90 | + graph = parse_graph(xml) |
82 | 91 | expect(graph.show_total).to(be_true) |
83 | 92 | result = graph.process(50, 100) |
84 | 93 | expect(result).to(have_key('showTotal', True)) |
|
101 | 110 | result = graph.process(50, 100) |
102 | 111 | expect(result).to(have_key('showTotal', True)) |
103 | 112 |
|
104 | | - with it('should always include showTotal in response'): |
105 | | - xml = """<?xml version="1.0"?> |
| 113 | + with it('should always include showTotal in response with correct value'): |
| 114 | + xml_no_domain = """<?xml version="1.0"?> |
106 | 115 | <graph string="My indicator" type="indicator" /> |
107 | 116 | """ |
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) |
| 117 | + graph_no_domain = parse_graph(xml_no_domain) |
| 118 | + result_no_domain = graph_no_domain.process(50, 100) |
| 119 | + expect(result_no_domain).to(have_key('showTotal')) |
| 120 | + expect(result_no_domain['showTotal']).to(be_false) |
| 121 | + |
| 122 | + xml_with_domain = """<?xml version="1.0"?> |
| 123 | + <graph string="My indicator" type="indicator" totalDomain="[]" /> |
| 124 | + """ |
| 125 | + graph_with_domain = parse_graph(xml_with_domain) |
| 126 | + result_with_domain = graph_with_domain.process(50, 100) |
| 127 | + expect(result_with_domain).to(have_key('showTotal')) |
| 128 | + expect(result_with_domain['showTotal']).to(be_true) |
112 | 129 |
|
113 | 130 | xml_false = """<?xml version="1.0"?> |
114 | 131 | <graph string="My indicator" showTotal="0" type="indicator" /> |
|
0 commit comments