test.py 989 Bytes
Newer Older
Chetan Sharma's avatar
Chetan Sharma committed
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
from sensors import Machine, Spindle, TFD
import time
import unittest


class TestMachine(unittest.TestCase):
    PORT = '/dev/ttyS25'

    def testMovement(self):
        machine = Machine(TestMachine.PORT)
        machine.unlock()
        machine.zero()
        machine.rapid(
            {
                'X' : 10,
                'Y' : 10,
            }
        )
        machine.cut(
            {
                'X' : 0,
                'Y' : 0,
            },
            100
        )
    def testState(self):
        machine = Machine(TestMachine.PORT)
        machine.unlock()
        state, coords, _ = machine.get_state()
        self.assertEqual(state, "Idle")
        self.assertEqual(coords, {'x':0, 'y': 0, 'z': 0})
        

# class TestTFD(unittest.TestCase):
#     PORT = '/dev/ttyS6'

#     def testForce(self):
#         tfd = TFD(TestTFD.PORT)
#         force = tfd.get_force()
#         self.assertNotEqual(force, 0)

if __name__ == '__main__':
    unittest.main()