diff --git a/ooui/graph/indicator.py b/ooui/graph/indicator.py
index 6f5a37c..75970b6 100644
--- a/ooui/graph/indicator.py
+++ b/ooui/graph/indicator.py
@@ -24,8 +24,10 @@ def __init__(self, graph_type, element):
) or None
self._show_percent = parse_bool_attribute(
element.get('showPercent')) if element.get('showPercent') else False
+ # showTotal is True by default only if totalDomain is defined, otherwise False
+ default_show_total = bool(self._total_domain)
self._show_total = parse_bool_attribute(
- element.get('showTotal')) if element.get('showTotal') else True
+ element.get('showTotal')) if element.get('showTotal') else default_show_total
self._progressbar = parse_bool_attribute(
element.get('progressbar')) if element.get('progressbar') else False
self.domain_parse_values = {}
diff --git a/spec/graph/graph_spec.py b/spec/graph/graph_spec.py
index 2d493dd..253b1c5 100644
--- a/spec/graph/graph_spec.py
+++ b/spec/graph/graph_spec.py
@@ -33,7 +33,7 @@
expect(graph.fields).to(contain_only('potencia'))
expect(graph.total_domain).to(be_none)
expect(graph.show_percent).to(be_true)
- expect(graph.show_total).to(be_true)
+ expect(graph.show_total).to(be_false) # False because no totalDomain
expect(graph.progressbar).to(be_false)
expect(graph.suffix).to(equal('kW'))
@@ -74,11 +74,20 @@
expect(result).not_to(have_key('progressbar'))
expect(result).not_to(have_key('showPercent'))
- with it('should include showTotal by default'):
+ with it('should not include showTotal by default when no totalDomain'):
xml = """
"""
graph = parse_graph(xml)
+ expect(graph.show_total).to(be_false)
+ result = graph.process(50, 100)
+ expect(result).to(have_key('showTotal', False))
+
+ with it('should include showTotal=True by default when totalDomain is defined'):
+ xml = """
+
+ """
+ graph = parse_graph(xml)
expect(graph.show_total).to(be_true)
result = graph.process(50, 100)
expect(result).to(have_key('showTotal', True))
@@ -101,14 +110,22 @@
result = graph.process(50, 100)
expect(result).to(have_key('showTotal', True))
- with it('should always include showTotal in response'):
- xml = """
+ with it('should always include showTotal in response with correct value'):
+ xml_no_domain = """
"""
- graph = parse_graph(xml)
- result = graph.process(50, 100)
- expect(result).to(have_key('showTotal'))
- expect(result['showTotal']).to(be_true)
+ graph_no_domain = parse_graph(xml_no_domain)
+ result_no_domain = graph_no_domain.process(50, 100)
+ expect(result_no_domain).to(have_key('showTotal'))
+ expect(result_no_domain['showTotal']).to(be_false)
+
+ xml_with_domain = """
+
+ """
+ graph_with_domain = parse_graph(xml_with_domain)
+ result_with_domain = graph_with_domain.process(50, 100)
+ expect(result_with_domain).to(have_key('showTotal'))
+ expect(result_with_domain['showTotal']).to(be_true)
xml_false = """
diff --git a/spec/graph/processor_spec.py b/spec/graph/processor_spec.py
index 8c81ec5..b28f6e6 100644
--- a/spec/graph/processor_spec.py
+++ b/spec/graph/processor_spec.py
@@ -43,7 +43,7 @@ def get_graph_data(xml, model):
"""
result = get_graph_data(xml, 'polissa')
expect(result).to(have_keys(
- value=275.72, color='red'
+ value=275.72, color='red', showTotal=False # False because no totalDomain
))
with it('should process indicatorField graph'):
@@ -68,7 +68,7 @@ def get_graph_data(xml, model):
icon='slack',
suffix='kW',
type='indicatorField',
- showTotal=True,
+ showTotal=True, # True because totalDomain="[]" is defined
))
with it('should process indicator graph'):