comparison py/test.py @ 144:482d7852b511

a bit more, and some tests
author Matt Johnston <matt@ucc.asn.au>
date Mon, 26 Nov 2012 23:21:03 +0800
parents
children 6517ddee3187
comparison
equal deleted inserted replaced
143:0895f5ad7731 144:482d7852b511
1 import unittest
2 import sensor_ds18b20
3
4 class TestSensors(unittest.TestCase):
5 def setUp(self):
6 self.sensors = sensor_ds18b20.DS18B20s(None)
7
8 def test_re(self):
9 f1 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 YES
10 6e 01 4b 46 7f ff 02 10 71 t=22875
11 """
12 val = self.sensors.do_sensor_name('blank', f1)
13 self.assertEqual(val, 22.875)
14
15 f2 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 NO
16 6e 01 4b 46 7f ff 02 10 71 t=22875
17 """
18 val = self.sensors.do_sensor_name('blank', f2)
19 self.assertEqual(val, None)
20
21 f3 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 YES
22 6e 01 4b 46 7f ff 02 10 71 t=-1
23 """
24 val = self.sensors.do_sensor_name('blank', f3)
25 self.assertEqual(val, -0.001)
26
27 unittest.main()