-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnectTestCase.py
44 lines (34 loc) · 1.22 KB
/
connectTestCase.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
import logging
import unittest
from servo_serial.connection import Connection
class ConnectTestCase(unittest.TestCase):
# this test must be run without error on win system
def testDetectNtSystem(self):
connect = Connection()
connect.getPortHandler()
connect.getPacketHandler()
def testSimilarityClassInstances(self):
connect1 = Connection()
connect2 = Connection()
self.assertEqual(connect1, connect2)
connect1.closePort()
connect2.closePort()
def testNotInitClosePort(self):
connect = Connection()
self.assertEqual(connect.closePort(), False)
connect.closePort()
def testInitClosePort(self):
connect = Connection()
connect.getPacketHandler()
self.assertEqual(connect.closePort(), True)
connect.closePort()
def testDefaultLoglevelAndChangeLogLevel(self):
connect = Connection()
level = connect.getLoggingLevel()
self.assertEqual(level, logging.ERROR)
targetLevel = logging.INFO
connect.setLogginLevel(targetLevel)
self.assertEqual(connect.getLoggingLevel(), targetLevel)
connect.closePort()
if __name__ == '__main__':
unittest.main()