Commit d5b0f7b0 authored by oroulet's avatar oroulet Committed by oroulet

add minimal sync Server and make test for it

parent 098b35d6
......@@ -2,7 +2,6 @@
sync API of asyncua
"""
import asyncio
import inspect
from threading import Thread, Condition
import logging
......@@ -109,8 +108,8 @@ def syncmethod(func):
class Client(client.Client):
def __init__(self, url: str, timeout: int = 4):
self._tloop = get_thread_loop()
client.Client.__init__(self, url, timeout, loop=self._tloop.loop)
global _tloop
client.Client.__init__(self, url, timeout, loop=_tloop.loop)
@syncmethod
def connect(self):
......@@ -121,4 +120,18 @@ class Client(client.Client):
pass
class Server(server.Server):
def __init__(self, shelf_file=None):
global _tloop
server.Server.__init__(self)
_tloop.post(self.init(shelf_file))
@syncmethod
def start(self):
pass
@syncmethod
def stop(self):
pass
......@@ -2,12 +2,16 @@ import time
import pytest
from opcua.sync import Client, start_thread_loop, stop_thread_loop
from opcua.sync import Client, start_thread_loop, stop_thread_loop, Server
@pytest.fixture
def server():
pass
s = Server()
s.set_endpoint('opc.tcp://*:8840/freeopcua/server/')
s.start()
yield s
s.stop()
@pytest.fixture
......@@ -18,8 +22,8 @@ def tloop():
@pytest.fixture
def client(tloop):
c = Client("opc.tcp://localhost:4840/freeopcua/server")
def client(tloop, server):
c = Client("opc.tcp://localhost:8840/freeopcua/server")
c.connect()
yield c
c.disconnect()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment