annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 import unittest
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 import sensor_ds18b20
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 class TestSensors(unittest.TestCase):
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 def setUp(self):
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 self.sensors = sensor_ds18b20.DS18B20s(None)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 def test_re(self):
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 f1 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 YES
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 6e 01 4b 46 7f ff 02 10 71 t=22875
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 """
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 val = self.sensors.do_sensor_name('blank', f1)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 self.assertEqual(val, 22.875)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 f2 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 NO
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 6e 01 4b 46 7f ff 02 10 71 t=22875
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 """
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 val = self.sensors.do_sensor_name('blank', f2)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 self.assertEqual(val, None)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 f3 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 YES
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 6e 01 4b 46 7f ff 02 10 71 t=-1
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 """
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 val = self.sensors.do_sensor_name('blank', f3)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 self.assertEqual(val, -0.001)
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26
482d7852b511 a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 unittest.main()