28
28
__copyright__ = "Copyright Sensors & Signals LLC https://www.snstac.com"
29
29
__license__ = "Apache License, Version 2.0"
30
30
31
+ __folder__ = os .path .dirname (__file__ )
31
32
32
33
def test_load_preferences () -> None :
33
34
"""Test loading a preferences file."""
34
- test_pref : str = "tests /data/test_pref.pref"
35
- prefs : dict = pytak .functions .load_preferences (test_pref , "tests /data" )
35
+ test_pref : str = __folder__ + " /data/test_pref.pref"
36
+ prefs : dict = pytak .functions .load_preferences (test_pref , __folder__ + " /data" )
36
37
assert all (prefs )
37
38
38
39
39
40
def test_load_connectString2url () -> None :
40
41
"""Test converting a TAK connectString to a URL"""
41
- test_pref : str = "tests /data/test_pref.pref"
42
- prefs : dict = pytak .functions .load_preferences (test_pref , "tests /data" )
42
+ test_pref : str = __folder__ + " /data/test_pref.pref"
43
+ prefs : dict = pytak .functions .load_preferences (test_pref , __folder__ + " /data" )
43
44
connect_string : str = prefs .get ("connect_string" )
44
45
url : str = pytak .functions .connectString2url (connect_string )
45
46
assert url == "ssl://takserver.example.com:8089"
46
47
47
48
48
49
def test_load_cert () -> None :
49
50
cert : list = pytak .crypto_functions .load_cert (
50
- "tests /data/test_user_cert.p12" , "atakatak"
51
+ __folder__ + " /data/test_user_cert.p12" , "atakatak"
51
52
)
52
53
assert len (cert ) == 3
53
54
54
55
55
56
def test_load_convert_cert ():
56
57
"""Test converting P12 certs to a PEM certs."""
57
- test_pref : str = "tests /data/test_pref.pref"
58
- prefs : dict = pytak .functions .load_preferences (test_pref , "tests /data" )
58
+ test_pref : str = __folder__ + " /data/test_pref.pref"
59
+ prefs : dict = pytak .functions .load_preferences (test_pref , __folder__ + " /data" )
59
60
60
61
client_password : str = prefs .get ("client_password" )
61
62
assert client_password
@@ -76,23 +77,23 @@ def test_load_convert_cert():
76
77
assert os .path .exists (cert_pem_path )
77
78
assert os .path .exists (ca_pem_path )
78
79
79
- with open ("tests /data/test_pk.pem" , "rb+" ) as tpk_fd :
80
+ with open (__folder__ + " /data/test_pk.pem" , "rb+" ) as tpk_fd :
80
81
test_pk = tpk_fd .read ()
81
82
with open (pk_pem_path , "rb+" ) as pk_fd :
82
83
assert pk_fd .read () == test_pk
83
84
84
- with open ("tests /data/test_user_cert.pem" , "rb+" ) as tc_fd :
85
+ with open (__folder__ + " /data/test_user_cert.pem" , "rb+" ) as tc_fd :
85
86
test_cert = tc_fd .read ()
86
87
with open (cert_pem_path , "rb+" ) as ck_fd :
87
88
assert ck_fd .read () == test_cert
88
89
89
- with open ("tests /data/test_ca_cert.pem" , "rb+" ) as tc_fd :
90
+ with open (__folder__ + " /data/test_ca_cert.pem" , "rb+" ) as tc_fd :
90
91
test_cert = tc_fd .read ()
91
92
with open (ca_pem_path , "rb+" ) as ck_fd :
92
93
assert ck_fd .read () == test_cert
93
94
94
95
95
96
def test_read_read_pref_package ():
96
- pref_package = "tests /data/test_pref_package.zip"
97
+ pref_package = __folder__ + " /data/test_pref_package.zip"
97
98
prefs = pytak .client_functions .read_pref_package (pref_package )
98
99
assert all (prefs )
0 commit comments