Completed
Push — master ( 52b12e...458b63 )
by Olivier
59s
created

TestClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A test_select_objects() 0 4 1
A tearDown() 0 3 1
1
2
import unittest
3
import sys
4
print("SYS:PATH", sys.path)
5
sys.path.insert(0, "python-opcua")
6
sys.path.insert(0, "opcua-widgets")
7
import os
8
print("PWD", os.getcwd())
9
10
from opcua import ua
11
from opcua import Server
12
13
from PyQt5.QtCore import QTimer, QSettings, QModelIndex, Qt, QCoreApplication
14
from PyQt5.QtWidgets import QApplication
15
from PyQt5.QtTest import QTest
16
17
from uaclient.mainwindow import Window
18
19
20
class TestClient(unittest.TestCase):
21
    def setUp(self):
22
        self.server = Server()
23
        url = "opc.tcp://localhost:48400/freeopcua/server/"
24
        self.server.set_endpoint(url)
25
        self.server.start()
26
        self.client = Window()
27
        self.client.ui.addrComboBox.setCurrentText(url)
28
        self.client.connect()
29
30
    def tearDown(self):
31
        self.client.disconnect()
32
        self.server.stop()
33
34
    def test_select_objects(self):
35
        objects = self.server.nodes.objects
36
        self.client.tree_ui.set_current_node("Objects")
37
        self.assertEqual(objects, self.client.tree_ui.get_current_node())
38
39
40
41
if __name__ == "__main__":
42
    app = QApplication(sys.argv)
43
    unittest.main()
44
45
46