-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
67 lines (56 loc) · 2.87 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from ADXL345 import *
import unittest
class TestADXL345(unittest.TestCase):
def test_who_am_i(self):
acc = ADXL345()
self.assertEqual(acc.whoAmI, ADXL345_WHO_AM_I_VAL)
def test_scale_2g(self):
acc = ADXL345(full_resolution=False) # full resolution is default so explicitly turn off
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_2G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_2G_TYP), b)
def test_scale_4g(self):
acc = ADXL345(sensitivity=ADXL345_ACC_SENSITIVITY_4G_TYP, scale=ADXL345_ACC_SCALE_4G, full_resolution=False) # full resolution is default so explicitly turn off
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_4G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_4G_TYP), b)
def test_scale_8g(self):
acc = ADXL345(sensitivity=ADXL345_ACC_SENSITIVITY_8G_TYP, scale=ADXL345_ACC_SCALE_8G, full_resolution=False) # full resolution is default so explicitly turn off
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_8G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_8G_TYP), b)
def test_scale_16g(self):
acc = ADXL345(sensitivity=ADXL345_ACC_SENSITIVITY_16G_TYP, scale=ADXL345_ACC_SCALE_16G, full_resolution=False) # full resolution is default so explicitly turn off
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_16G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_16G_TYP), b)
def test_full_res_2g(self):
acc = ADXL345() # full resolution is default
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_2G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_2G_TYP), b)
def test_full_res_4g(self):
acc = ADXL345(scale=ADXL345_ACC_SCALE_4G) # full resolution is default
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_2G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_2G_TYP), b)
def test_full_res_8g(self):
acc = ADXL345(scale=ADXL345_ACC_SCALE_8G) # full resolution is default
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_2G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_2G_TYP), b)
def test_full_res_16g(self):
acc = ADXL345(scale=ADXL345_ACC_SCALE_16G) # full resolution is default
data = acc.getXYZ()
c = [(d/ADXL345_ACC_SENSITIVITY_2G_TYP) for d in data]
for (a,b) in zip(c, data):
self.assertEqual((a*ADXL345_ACC_SENSITIVITY_2G_TYP), b)
if __name__ == '__main__':
unittest.main()