va_test_connection.py 1.19 KB
Newer Older
1 2 3
# VA is used as a singleton.
# You can access va in every script, function and method.

4 5 6
# Add va module if it was not installed
import sys
sys.path.append( '../Lib/site-packages' ) # deploy structure
7 8 9

import va

10
print( "Testing va extension connection methods." )
11

12 13 14
if va.connect() :
	print( "Successfully connected to local server without arguments" )
	va.disconnect() # direct disconnect
15
else :
16 17
	print( "Connection failed" )

18 19 20 21 22 23
if va.connect( "localhost" ) :
	print( "Successfully connected to local server with localhost argument" )
else :
	print( "Connection failed" )

# sensitive disconnect
24
if va.is_connected() :
25
	va.disconnect()
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

if va.connect( "localhost", 12340 ) :
	print( "Successfully connected to local server with localhost and port 12340 argument" )
else :
	print( "Connection failed" )

print( "Disconnect." )
va.disconnect()

import time

import warnings

with warnings.catch_warnings() :
	warnings.simplefilter( "always" )
41
	
42 43 44 45 46 47 48 49 50 51 52
	time.sleep( 1 )
	print( "Double disconnect:" )
	va.disconnect() # double disconnect should raise warning

	va.connect()

	time.sleep( 1 )
	print( "Double connect:" )
	va.connect() # double connect should raise forced disconnection warning

va.disconnect()
53
print( "Test done." )