| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
import codecs |
| 4 |
import getopt |
| 5 |
import json |
| 6 |
import math |
| 7 |
import os |
| 8 |
import shlex |
| 9 |
import socket |
| 10 |
import sys |
| 11 |
import textwrap |
| 12 |
import threading |
| 13 |
import time |
| 14 |
import unittest |
| 15 |
from sys import platform |
| 16 |
|
| 17 |
import varlink |
| 18 |
|
| 19 |
######## CLIENT ############# |
| 20 |
|
| 21 |
|
| 22 |
def run_client(client): |
| 23 |
print(f"Connecting to {client}\n") |
| 24 |
with client.open("org.varlink.certification") as con: |
| 25 |
ret = con.Start() |
| 26 |
client_id = ret["client_id"] |
| 27 |
print("client_id:", client_id) |
| 28 |
ret = con.Test01(client_id) |
| 29 |
print("Test01:", ret) |
| 30 |
ret = con.Test02(client_id, ret["bool"]) |
| 31 |
print("Test02:", ret) |
| 32 |
ret = con.Test03(client_id, ret["int"]) |
| 33 |
print("Test03:", ret) |
| 34 |
ret = con.Test04(client_id, ret["float"]) |
| 35 |
print("Test04:", ret) |
| 36 |
ret = con.Test05(client_id, ret["string"]) |
| 37 |
print("Test05:", ret) |
| 38 |
ret = con.Test06(client_id, ret["bool"], ret["int"], ret["float"], ret["string"]) |
| 39 |
print("Test06:", ret) |
| 40 |
ret = con.Test07(client_id, ret["struct"]) |
| 41 |
print("Test07:", ret) |
| 42 |
ret = con.Test08(client_id, ret["map"]) |
| 43 |
print("Test08:", ret) |
| 44 |
ret = con.Test09(client_id, ret["set"]) |
| 45 |
print("Test09:", ret) |
| 46 |
ret_array = [] |
| 47 |
for ret in con.Test10(client_id, ret["mytype"], _more=True): |
| 48 |
print("Test10:", ret) |
| 49 |
ret_array.append(ret["string"]) |
| 50 |
ret = con.Test11(client_id, ret_array, _oneway=True) |
| 51 |
print("Test11:", ret) |
| 52 |
ret = con.End(client_id) |
| 53 |
print("End:", ret) |
| 54 |
print("Certification passed") |
| 55 |
|
| 56 |
|
| 57 |
######## SERVER ############# |
| 58 |
|
| 59 |
service = varlink.Service( |
| 60 |
vendor="Varlink", |
| 61 |
product="Varlink Examples", |
| 62 |
version="1", |
| 63 |
url="http://varlink.org", |
| 64 |
interface_dir=os.path.dirname(__file__), |
| 65 |
) |
| 66 |
|
| 67 |
|
| 68 |
class ServiceRequestHandler(varlink.RequestHandler): |
| 69 |
service = service |
| 70 |
|
| 71 |
|
| 72 |
def sorted_json(dct): |
| 73 |
if isinstance(dct, type([])): |
| 74 |
return sorted(dct) |
| 75 |
return dct |
| 76 |
|
| 77 |
|
| 78 |
class CertificationError(varlink.VarlinkError): |
| 79 |
def __init__(self, wants, got): |
| 80 |
varlink.VarlinkError.__init__( |
| 81 |
self, |
| 82 |
{ |
| 83 |
"error": "org.varlink.certification.CertificationError", |
| 84 |
"parameters": {"wants": wants, "got": got}, |
| 85 |
}, |
| 86 |
) |
| 87 |
|
| 88 |
|
| 89 |
@service.interface("org.varlink.certification") |
| 90 |
class CertService: |
| 91 |
next_method: dict[str, str] = {} |
| 92 |
|
| 93 |
def new_client_id(self, _server): |
| 94 |
client_id = codecs.getencoder("hex")(os.urandom(16))[0].decode("ascii") |
| 95 |
if not hasattr(_server, "next_method"): |
| 96 |
_server.next_method = {} |
| 97 |
if not hasattr(_server, "lifetimes"): |
| 98 |
_server.lifetimes = [] |
| 99 |
|
| 100 |
_server.next_method[client_id] = "Start" |
| 101 |
_server.lifetimes.append((time.time(), client_id)) |
| 102 |
return client_id |
| 103 |
|
| 104 |
def check_lifetimes(self, _server): |
| 105 |
if not hasattr(_server, "lifetimes"): |
| 106 |
return |
| 107 |
|
| 108 |
now = time.time() |
| 109 |
while True: |
| 110 |
if len(_server.lifetimes) == 0: |
| 111 |
return |
| 112 |
|
| 113 |
(t, client_id) = _server.lifetimes[0] |
| 114 |
if (now - t) < (60 * 60 * 12): |
| 115 |
return |
| 116 |
|
| 117 |
del _server.lifetimes[0] |
| 118 |
if hasattr(_server, "next_method") and client_id in _server.next_method: |
| 119 |
del _server.next_method[client_id] |
| 120 |
|
| 121 |
def assert_raw(self, client_id, _server, _raw, _message, wants): |
| 122 |
if wants != _message: |
| 123 |
del _server.next_method[client_id] |
| 124 |
raise CertificationError(wants, json.loads(_raw.decode("utf-8"))) |
| 125 |
|
| 126 |
def assert_cmp(self, client_id, _server, _raw, wants, _bool): |
| 127 |
if not _bool: |
| 128 |
del _server.next_method[client_id] |
| 129 |
raise CertificationError(wants, json.loads(_raw.decode("utf-8"))) |
| 130 |
|
| 131 |
def assert_method(self, client_id, _server, from_method, next_method): |
| 132 |
if not hasattr(_server, "next_method") or client_id not in _server.next_method: |
| 133 |
raise CertificationError( |
| 134 |
{"method": "org.varlink.certification.Start+++"}, |
| 135 |
{"method": "org.varlink.certification." + from_method}, |
| 136 |
) |
| 137 |
|
| 138 |
self.check_lifetimes(_server) |
| 139 |
|
| 140 |
if from_method != _server.next_method[client_id]: |
| 141 |
raise CertificationError( |
| 142 |
"Call to method org.varlink.certification." + _server.next_method[client_id], |
| 143 |
"Call to method org.varlink.certification." + from_method, |
| 144 |
) |
| 145 |
_server.next_method[client_id] = next_method |
| 146 |
|
| 147 |
def Start(self, _server=None, _raw=None, _message=None, _oneway=False): |
| 148 |
client_id = self.new_client_id(_server) |
| 149 |
if "parameters" in _message and not _message["parameters"]: |
| 150 |
del _message["parameters"] |
| 151 |
self.assert_method(client_id, _server, "Start", "Test01") |
| 152 |
self.assert_raw( |
| 153 |
client_id, |
| 154 |
_server, |
| 155 |
_raw, |
| 156 |
_message, |
| 157 |
{ |
| 158 |
"method": "org.varlink.certification.Start", |
| 159 |
}, |
| 160 |
) |
| 161 |
return {"client_id": client_id} |
| 162 |
|
| 163 |
# () -> (bool: bool) |
| 164 |
def Test01(self, client_id, _server=None, _raw=None, _message=None): |
| 165 |
self.assert_method(client_id, _server, "Test01", "Test02") |
| 166 |
self.assert_raw( |
| 167 |
client_id, |
| 168 |
_server, |
| 169 |
_raw, |
| 170 |
_message, |
| 171 |
{ |
| 172 |
"method": "org.varlink.certification.Test01", |
| 173 |
"parameters": {"client_id": client_id}, |
| 174 |
}, |
| 175 |
) |
| 176 |
return {"bool": True} |
| 177 |
|
| 178 |
# (bool: bool) -> (int: int) |
| 179 |
def Test02(self, client_id, _bool, _server=None, _raw=None, _message=None): |
| 180 |
self.assert_method(client_id, _server, "Test02", "Test03") |
| 181 |
wants = { |
| 182 |
"method": "org.varlink.certification.Test02", |
| 183 |
"parameters": {"client_id": client_id, "bool": True}, |
| 184 |
} |
| 185 |
self.assert_cmp(client_id, _server, _raw, wants, _bool == True) # noqa: E712 |
| 186 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 187 |
return {"int": 1} |
| 188 |
|
| 189 |
# (int: int) -> (float: float) |
| 190 |
def Test03(self, client_id, _int, _server=None, _raw=None, _message=None): |
| 191 |
self.assert_method(client_id, _server, "Test03", "Test04") |
| 192 |
wants = { |
| 193 |
"method": "org.varlink.certification.Test03", |
| 194 |
"parameters": {"client_id": client_id, "int": 1}, |
| 195 |
} |
| 196 |
self.assert_cmp(client_id, _server, _raw, wants, _int == 1) |
| 197 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 198 |
return {"float": 1.0} |
| 199 |
|
| 200 |
# (float: float) -> (string: string) |
| 201 |
def Test04(self, client_id, _float, _server=None, _raw=None, _message=None): |
| 202 |
self.assert_method(client_id, _server, "Test04", "Test05") |
| 203 |
wants = { |
| 204 |
"method": "org.varlink.certification.Test04", |
| 205 |
"parameters": {"client_id": client_id, "float": 1.0}, |
| 206 |
} |
| 207 |
self.assert_cmp(client_id, _server, _raw, wants, _float == 1.0) |
| 208 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 209 |
return {"string": "ping"} |
| 210 |
|
| 211 |
# (string: string) -> (bool: bool, int: int, float: float, string: string) |
| 212 |
def Test05(self, client_id, _string, _server=None, _raw=None, _message=None): |
| 213 |
self.assert_method(client_id, _server, "Test05", "Test06") |
| 214 |
wants = { |
| 215 |
"method": "org.varlink.certification.Test05", |
| 216 |
"parameters": {"client_id": client_id, "string": "ping"}, |
| 217 |
} |
| 218 |
self.assert_cmp(client_id, _server, _raw, wants, _string == "ping") |
| 219 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 220 |
return {"bool": False, "int": 2, "float": math.pi, "string": "a lot of string"} |
| 221 |
|
| 222 |
# (bool: bool, int: int, float: float, string: string) |
| 223 |
# -> (struct: (bool: bool, int: int, float: float, string: string)) |
| 224 |
def Test06(self, client_id, _bool, _int, _float, _string, _server=None, _raw=None, _message=None): |
| 225 |
self.assert_method(client_id, _server, "Test06", "Test07") |
| 226 |
wants = { |
| 227 |
"method": "org.varlink.certification.Test06", |
| 228 |
"parameters": { |
| 229 |
"client_id": client_id, |
| 230 |
"bool": False, |
| 231 |
"int": 2, |
| 232 |
"float": math.pi, |
| 233 |
"string": "a lot of string", |
| 234 |
}, |
| 235 |
} |
| 236 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 237 |
self.assert_cmp(client_id, _server, _raw, wants, _int == 2) |
| 238 |
self.assert_cmp(client_id, _server, _raw, wants, _bool == False) # noqa: E712 |
| 239 |
self.assert_cmp(client_id, _server, _raw, wants, _float == math.pi) |
| 240 |
self.assert_cmp(client_id, _server, _raw, wants, _string == "a lot of string") |
| 241 |
|
| 242 |
return {"struct": {"bool": False, "int": 2, "float": math.pi, "string": "a lot of string"}} |
| 243 |
|
| 244 |
# (struct: (bool: bool, int: int, float: float, string: string)) -> (map: [string]string) |
| 245 |
def Test07(self, client_id, _dict, _server=None, _raw=None, _message=None): |
| 246 |
self.assert_method(client_id, _server, "Test07", "Test08") |
| 247 |
wants = { |
| 248 |
"method": "org.varlink.certification.Test07", |
| 249 |
"parameters": { |
| 250 |
"client_id": client_id, |
| 251 |
"struct": {"bool": False, "int": 2, "float": math.pi, "string": "a lot of string"}, |
| 252 |
}, |
| 253 |
} |
| 254 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 255 |
self.assert_cmp(client_id, _server, _raw, wants, _dict["int"] == 2) |
| 256 |
self.assert_cmp(client_id, _server, _raw, wants, _dict["bool"] == False) # noqa: E712 |
| 257 |
self.assert_cmp(client_id, _server, _raw, wants, _dict["float"] == math.pi) |
| 258 |
self.assert_cmp(client_id, _server, _raw, wants, _dict["string"] == "a lot of string") |
| 259 |
return {"map": {"foo": "Foo", "bar": "Bar"}} |
| 260 |
|
| 261 |
# (map: [string]string) -> (set: [string]()) |
| 262 |
def Test08(self, client_id, _map, _server=None, _raw=None, _message=None): |
| 263 |
self.assert_method(client_id, _server, "Test08", "Test09") |
| 264 |
self.assert_raw( |
| 265 |
client_id, |
| 266 |
_server, |
| 267 |
_raw, |
| 268 |
_message, |
| 269 |
{ |
| 270 |
"method": "org.varlink.certification.Test08", |
| 271 |
"parameters": {"client_id": client_id, "map": {"foo": "Foo", "bar": "Bar"}}, |
| 272 |
}, |
| 273 |
) |
| 274 |
return {"set": {"one", "two", "three"}} |
| 275 |
|
| 276 |
# (set: [string]()) -> (mytype: MyType) |
| 277 |
def Test09(self, client_id, _set, _server=None, _raw=None, _message=None): |
| 278 |
self.assert_method(client_id, _server, "Test09", "Test10") |
| 279 |
wants = { |
| 280 |
"method": "org.varlink.certification.Test09", |
| 281 |
"parameters": {"client_id": client_id, "set": {"one": {}, "three": {}, "two": {}}}, |
| 282 |
} |
| 283 |
self.assert_raw(client_id, _server, _raw, _message, wants) |
| 284 |
self.assert_cmp(client_id, _server, _raw, wants, isinstance(_set, set)) |
| 285 |
self.assert_cmp(client_id, _server, _raw, wants, len(_set) == 3) |
| 286 |
self.assert_cmp(client_id, _server, _raw, wants, "one" in _set) |
| 287 |
self.assert_cmp(client_id, _server, _raw, wants, "two" in _set) |
| 288 |
self.assert_cmp(client_id, _server, _raw, wants, "three" in _set) |
| 289 |
return { |
| 290 |
"mytype": { |
| 291 |
"object": { |
| 292 |
"method": "org.varlink.certification.Test09", |
| 293 |
"parameters": {"map": {"foo": "Foo", "bar": "Bar"}}, |
| 294 |
}, |
| 295 |
"enum": "two", |
| 296 |
"struct": {"first": 1, "second": "2"}, |
| 297 |
"array": ["one", "two", "three"], |
| 298 |
"dictionary": {"foo": "Foo", "bar": "Bar"}, |
| 299 |
"stringset": {"one", "two", "three"}, |
| 300 |
"nullable": None, |
| 301 |
"nullable_array_struct": None, |
| 302 |
"interface": { |
| 303 |
"foo": [ |
| 304 |
None, |
| 305 |
{"foo": "foo", "bar": "bar"}, |
| 306 |
None, |
| 307 |
{"one": "foo", "two": "bar"}, |
| 308 |
], |
| 309 |
"anon": {"foo": True, "bar": False}, |
| 310 |
}, |
| 311 |
}, |
| 312 |
} |
| 313 |
|
| 314 |
# method Test10(mytype: MyType) -> (string: string) |
| 315 |
def Test10(self, client_id, mytype, _server=None, _raw=None, _message=None): |
| 316 |
self.assert_method(client_id, _server, "Test10", "Test11") |
| 317 |
|
| 318 |
wants = { |
| 319 |
"method": "org.varlink.certification.Test10", |
| 320 |
"more": True, |
| 321 |
"parameters": { |
| 322 |
"client_id": client_id, |
| 323 |
"mytype": { |
| 324 |
"object": { |
| 325 |
"method": "org.varlink.certification.Test09", |
| 326 |
"parameters": {"map": {"foo": "Foo", "bar": "Bar"}}, |
| 327 |
}, |
| 328 |
"enum": "two", |
| 329 |
"struct": {"first": 1, "second": "2"}, |
| 330 |
"array": ["one", "two", "three"], |
| 331 |
"dictionary": {"foo": "Foo", "bar": "Bar"}, |
| 332 |
"stringset": {"one", "two", "three"}, |
| 333 |
"interface": { |
| 334 |
"foo": [ |
| 335 |
None, |
| 336 |
{"foo": "foo", "bar": "bar"}, |
| 337 |
None, |
| 338 |
{"one": "foo", "two": "bar"}, |
| 339 |
], |
| 340 |
"anon": {"foo": True, "bar": False}, |
| 341 |
}, |
| 342 |
}, |
| 343 |
}, |
| 344 |
} |
| 345 |
|
| 346 |
if "nullable" in mytype: |
| 347 |
self.assert_cmp(client_id, _server, _raw, wants, mytype["nullable"] is None) |
| 348 |
del mytype["nullable"] |
| 349 |
|
| 350 |
if "nullable_array_struct" in mytype: |
| 351 |
self.assert_cmp(client_id, _server, _raw, wants, mytype["nullable_array_struct"] is None) |
| 352 |
del mytype["nullable_array_struct"] |
| 353 |
|
| 354 |
self.assert_cmp(client_id, _server, _raw, wants, mytype == wants["parameters"]["mytype"]) |
| 355 |
|
| 356 |
for i in range(1, 11): |
| 357 |
yield {"string": f"Reply number {i}", "_continues": i != 10} |
| 358 |
|
| 359 |
# method Test11(last_more_replies: []string) -> () |
| 360 |
def Test11(self, client_id, last_more_replies, _server=None, _raw=None, _message=None, _oneway=False): |
| 361 |
self.assert_method(client_id, _server, "Test11", "End") |
| 362 |
wants = { |
| 363 |
"oneway": True, |
| 364 |
"method": "org.varlink.certification.Test11", |
| 365 |
"parameters": { |
| 366 |
"client_id": client_id, |
| 367 |
"last_more_replies": [ |
| 368 |
"Reply number 1", |
| 369 |
"Reply number 2", |
| 370 |
"Reply number 3", |
| 371 |
"Reply number 4", |
| 372 |
"Reply number 5", |
| 373 |
"Reply number 6", |
| 374 |
"Reply number 7", |
| 375 |
"Reply number 8", |
| 376 |
"Reply number 9", |
| 377 |
"Reply number 10", |
| 378 |
], |
| 379 |
}, |
| 380 |
} |
| 381 |
|
| 382 |
self.assert_cmp(client_id, _server, _raw, wants, _oneway) |
| 383 |
|
| 384 |
for i in range(0, 10): |
| 385 |
self.assert_cmp(client_id, _server, _raw, wants, last_more_replies[i] == f"Reply number {i + 1}") |
| 386 |
|
| 387 |
# method End() -> () |
| 388 |
def End(self, client_id, _server=None, _raw=None, _message=None): |
| 389 |
self.assert_method(client_id, _server, "End", "Start") |
| 390 |
|
| 391 |
self.assert_raw( |
| 392 |
client_id, |
| 393 |
_server, |
| 394 |
_raw, |
| 395 |
_message, |
| 396 |
{"method": "org.varlink.certification.End", "parameters": {"client_id": client_id}}, |
| 397 |
) |
| 398 |
|
| 399 |
del _server.next_method[client_id] |
| 400 |
return {"all_ok": True} |
| 401 |
|
| 402 |
|
| 403 |
def run_server(address): |
| 404 |
with varlink.ThreadingServer(address, ServiceRequestHandler) as server: |
| 405 |
print("Listening on", server.server_address) |
| 406 |
try: |
| 407 |
server.serve_forever() |
| 408 |
except KeyboardInterrupt: |
| 409 |
pass |
| 410 |
|
| 411 |
|
| 412 |
######## MAIN ############# |
| 413 |
|
| 414 |
|
| 415 |
def usage(): |
| 416 |
arg0 = sys.argv[0] |
| 417 |
print( |
| 418 |
textwrap.dedent( |
| 419 |
f"""\ |
| 420 |
Usage: {arg0} [[--client] --varlink=<varlink address>] |
| 421 |
\tSelf Exec: $ {arg0} |
| 422 |
\tServer : $ {arg0} --varlink=<varlink address> |
| 423 |
\tClient : $ {arg0} --client --varlink=<varlink address> |
| 424 |
\tClient : $ {arg0} --client --bridge=<bridge command> |
| 425 |
\tClient : $ {arg0} --client --activate=<activation command> |
| 426 |
""" |
| 427 |
), |
| 428 |
file=sys.stderr, |
| 429 |
) |
| 430 |
|
| 431 |
|
| 432 |
if __name__ == "__main__": |
| 433 |
try: |
| 434 |
opts, args = getopt.getopt( |
| 435 |
sys.argv[1:], "b:A:", ["help", "client", "varlink=", "bridge=", "activate="] |
| 436 |
) |
| 437 |
except getopt.GetoptError: |
| 438 |
usage() |
| 439 |
sys.exit(2) |
| 440 |
|
| 441 |
address = None |
| 442 |
client_mode = False |
| 443 |
activate = None |
| 444 |
bridge = None |
| 445 |
|
| 446 |
for opt, arg in opts: |
| 447 |
if opt == "--help": |
| 448 |
usage() |
| 449 |
sys.exit(0) |
| 450 |
elif opt == "--varlink": |
| 451 |
address = arg |
| 452 |
elif opt == "--bridge" or opt == "-b": |
| 453 |
bridge = arg |
| 454 |
elif opt == "--activate" or opt == "-A": |
| 455 |
activate = arg |
| 456 |
elif opt == "--client": |
| 457 |
client_mode = True |
| 458 |
|
| 459 |
client = None |
| 460 |
|
| 461 |
if client_mode: |
| 462 |
if bridge: |
| 463 |
client = varlink.Client.new_with_bridge(shlex.split(bridge)) |
| 464 |
if activate: |
| 465 |
client = varlink.Client.new_with_activate(shlex.split(activate)) |
| 466 |
if address: |
| 467 |
client = varlink.Client.new_with_address(address) |
| 468 |
|
| 469 |
if not address and not client_mode: |
| 470 |
if not hasattr(socket, "AF_UNIX"): |
| 471 |
print(f"varlink activate: not supported on platform {platform}", file=sys.stderr) |
| 472 |
usage() |
| 473 |
sys.exit(2) |
| 474 |
|
| 475 |
client_mode = True |
| 476 |
with varlink.Client.new_with_activate([__file__, "--varlink=$VARLINK_ADDRESS"]) as client: |
| 477 |
run_client(client) |
| 478 |
elif client_mode: |
| 479 |
if client is None: |
| 480 |
raise ValueError("--client requires at either of --varlink, --bridge or --activate") |
| 481 |
with client: |
| 482 |
run_client(client) |
| 483 |
else: |
| 484 |
run_server(address) |
| 485 |
|
| 486 |
sys.exit(0) |
| 487 |
|
| 488 |
|
| 489 |
######## UNITTEST ############# |
| 490 |
|
| 491 |
|
| 492 |
class TestService(unittest.TestCase): |
| 493 |
@classmethod |
| 494 |
def setUpClass(cls): |
| 495 |
if hasattr(socket, "AF_UNIX"): |
| 496 |
cls.address = ( |
| 497 |
"unix:org.varlink.certification_" + str(os.getpid()) + threading.current_thread().name |
| 498 |
) |
| 499 |
else: |
| 500 |
cls.address = "tcp:127.0.0.1:23456" |
| 501 |
|
| 502 |
cls.server = varlink.ThreadingServer(cls.address, ServiceRequestHandler) |
| 503 |
server_thread = threading.Thread(target=cls.server.serve_forever) |
| 504 |
server_thread.daemon = True |
| 505 |
server_thread.start() |
| 506 |
|
| 507 |
def test_client(self): |
| 508 |
run_client(varlink.Client.new_with_address(self.address)) |
| 509 |
|
| 510 |
def test_01(self): |
| 511 |
with varlink.Client(self.address) as client, client.open("org.varlink.certification") as con: |
| 512 |
ret = con.Start() |
| 513 |
client_id = ret["client_id"] |
| 514 |
ret = con.Test01(client_id) |
| 515 |
print("Test01:", ret) |
| 516 |
ret = con.Test02(client_id, ret["bool"]) |
| 517 |
print("Test02:", ret) |
| 518 |
self.assertRaises(varlink.VarlinkError, con.Test03, "test") |
| 519 |
self.assertRaises(varlink.VarlinkError, con.Test03, client_id, 0) |
| 520 |
self.assertRaises(varlink.VarlinkError, con.Test03, client_id, ret["int"]) |
| 521 |
ret = con.Start() |
| 522 |
client_id = ret["client_id"] |
| 523 |
ret = con.Test01(client_id) |
| 524 |
print("Test01:", ret) |
| 525 |
ret = con.Test02(client_id, ret["bool"]) |
| 526 |
print("Test02:", ret) |
| 527 |
self.assertRaises(varlink.VarlinkError, con.Test01, client_id) |
| 528 |
|
| 529 |
@classmethod |
| 530 |
def tearDownClass(cls): |
| 531 |
cls.server.shutdown() |
| 532 |
cls.server.server_close() |