comparison py/test.py @ 294:6bacd8ca9f8f

merge
author Matt Johnston <matt@ucc.asn.au>
date Sat, 06 Jul 2019 18:30:25 +0800
parents 74c3ae4e3307
children
comparison
equal deleted inserted replaced
293:d15dda1b1f76 294:6bacd8ca9f8f
1 #!/usr/bin/env python2.7
2 import io 1 import io
3 2
4 import unittest 3 import unittest
5 import sensor_ds18b20 4 import sensor_ds18b20
6 import params 5 import params
7 6
8 class TestSensors(unittest.TestCase): 7 class TestSensors(unittest.TestCase):
9 def setUp(self): 8 def setUp(self):
10 self.sensors = sensor_ds18b20.DS18B20s(None) 9 self.sensors = sensor_ds18b20.SensorDS18B20(None)
11 10
12 def test_sensors_regex(self): 11 def test_sensors_regex(self):
13 f1 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 YES 12 f1 = """6e 01 4b 46 7f ff 02 10 71 : crc=71 YES
14 6e 01 4b 46 7f ff 02 10 71 t=22875 13 6e 01 4b 46 7f ff 02 10 71 t=22875
15 """ 14 """
64 63
65 def test_params_save(self): 64 def test_params_save(self):
66 jsbuf = io.StringIO() 65 jsbuf = io.StringIO()
67 66
68 self.params.overshoot_delay = 123 67 self.params.overshoot_delay = 123
69 self.params.save(f=jsbuf) 68 s = self.params.save_string()
70
71 s = jsbuf.getvalue()
72 self.assertTrue('"overshoot_delay": 123' in s, msg=s) 69 self.assertTrue('"overshoot_delay": 123' in s, msg=s)
73 70
74 unittest.main() 71 unittest.main()