annotate py/test.py @ 443:bca470d153fd

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
443
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 import unittest
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 import sensor_ds18b20
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 class TestSensors(unittest.TestCase):
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 def setUp(self):
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 self.sensors = sensor_ds18b20.DS18B20s(None)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 def test_re(self):
bca470d153fd 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
bca470d153fd 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
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 """
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 val = self.sensors.do_sensor_name('blank', f1)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 self.assertEqual(val, 22.875)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14
bca470d153fd 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
bca470d153fd 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
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 """
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 val = self.sensors.do_sensor_name('blank', f2)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 self.assertEqual(val, None)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20
bca470d153fd 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
bca470d153fd 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
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 """
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 val = self.sensors.do_sensor_name('blank', f3)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 self.assertEqual(val, -0.001)
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26
bca470d153fd a bit more, and some tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 unittest.main()