Fixed problem when one of the trend values is None.

Regression test in test suites.
This commit is contained in:
Tom Keffer
2014-11-01 21:06:48 +00:00
parent 550a7f00a4
commit c834cb882e
4 changed files with 17 additions and 1 deletions

View File

@@ -440,7 +440,10 @@ class TrendObj(object):
# F_to_C(68F - 50F). We want the former, not the latter.
now_vtc = self.converter.convert(now_vt)
then_vtc = self.converter.convert(then_vt)
trend = now_vtc - then_vtc
if now_vtc.value is None or then_vtc.value is None:
trend = ValueTuple(None, now_vtc.unit, now_vtc.group)
else:
trend = now_vtc - then_vtc
# Return the results as a ValueHelper. Use the formatting and labeling
# options from the current time record. The user can always override

View File

@@ -91,6 +91,10 @@
<td>Outside Temperature trend with explicit time_delta (3600 seconds)</td>
<td>4.4&#176;F</td>
</tr>
<tr>
<td>Outside Temperature trend where previous value is known to be None (9000 seconds)</td>
<td> N/A</td>
</tr>
<tr>
<td>Trend with nonsense type</td>
<td>?'foobar'?</td>

View File

@@ -91,6 +91,10 @@
<td>Outside Temperature trend with explicit time_delta (3600 seconds)</td>
<td>2.4&#176;C</td>
</tr>
<tr>
<td>Outside Temperature trend where previous value is known to be None (9000 seconds)</td>
<td> N/A</td>
</tr>
<tr>
<td>Trend with nonsense type</td>
<td>?'foobar'?</td>

View File

@@ -98,6 +98,11 @@
<td>Outside Temperature trend with explicit time_delta (3600 seconds)</td>
<td>$trend($time_delta=3600).outTemp</td>
</tr>
<tr>
## This test uses a previous value known to be None:
<td>Outside Temperature trend where previous value is known to be None (9000 seconds)</td>
<td>$trend($time_delta=9000).outTemp</td>
</tr>
<tr>
<td>Trend with nonsense type</td>
<td>$trend.foobar</td>