|
1 | | -import os |
2 | | -import io |
3 | | -import tempfile |
| 1 | +import base64 |
4 | 2 | import contextlib |
5 | | -import shutil |
| 3 | +import io |
| 4 | +import datetime |
6 | 5 | import hashlib |
7 | | -import base64 |
| 6 | +import inspect |
| 7 | +import json |
8 | 8 | import logging |
9 | 9 | import math |
| 10 | +import os |
| 11 | +import shutil |
10 | 12 | import socket |
11 | | -import inspect |
12 | | -import threading |
13 | 13 | import random |
14 | | -import datetime |
15 | | -import json |
| 14 | +import re |
16 | 15 | import sys |
| 16 | +import tempfile |
| 17 | +import threading |
| 18 | + |
17 | 19 | import irods.client_configuration as config |
18 | | -import irods.rule |
19 | | -from irods.session import iRODSSession |
| 20 | +from irods.helpers import ( |
| 21 | + home_collection, |
| 22 | + make_session as _irods_helpers_make_session) |
20 | 23 | from irods.message import iRODSMessage, IRODS_VERSION |
21 | 24 | from irods.password_obfuscation import encode |
22 | | -from irods import env_filename_from_keyword_args |
| 25 | +import irods.rule |
| 26 | +from irods.session import iRODSSession |
23 | 27 |
|
24 | 28 |
|
25 | 29 | class iRODSUserLogins: |
@@ -76,19 +80,6 @@ def configuration_file_exists(): |
76 | 80 | return True |
77 | 81 |
|
78 | 82 |
|
79 | | -class StopTestsException(Exception): |
80 | | - |
81 | | - def __init__(self, *args, **kwargs): |
82 | | - super(StopTestsException, self).__init__(*args, **kwargs) |
83 | | - if "unittest" in sys.modules.keys(): |
84 | | - print("Aborting tests [ Got : %r ]" % self, file=sys.stderr) |
85 | | - os.abort() |
86 | | - |
87 | | - |
88 | | -class iRODS_Server_Too_Recent(StopTestsException): |
89 | | - pass |
90 | | - |
91 | | - |
92 | 83 | def my_function_name(): |
93 | 84 | """Returns the name of the calling function or method""" |
94 | 85 | return inspect.getframeinfo(inspect.currentframe().f_back).function |
@@ -172,48 +163,13 @@ def recast(k): |
172 | 163 | return (config, auth) |
173 | 164 |
|
174 | 165 |
|
175 | | -def get_server_version_for_test(session, curtail_length): |
176 | | - return session._server_version(session.GET_SERVER_VERSION_WITHOUT_AUTH)[ |
177 | | - :curtail_length |
178 | | - ] |
179 | | - |
180 | | - |
181 | | -# Create a connection for test, based on ~/.irods environment by default. |
| 166 | +def make_session(test_server_version=True, **kwargs): |
| 167 | + return _irods_helpers_make_session(test_server_version=test_server_version, **kwargs) |
182 | 168 |
|
183 | 169 |
|
184 | | -def make_session(test_server_version=True, **kwargs): |
185 | | - """Connect to an iRODS server as determined by any client environment |
186 | | - file present at a standard location, and by any keyword arguments given. |
187 | | -
|
188 | | - Arguments: |
189 | | -
|
190 | | - test_server_version: Of type bool; in the `irods.test.helpers` version of this |
191 | | - function, defaults to True. A True value causes |
192 | | - *iRODS_Server_Too_Recent* to be raised if the server |
193 | | - connected to is more recent than the current Python iRODS |
194 | | - client's advertised level of compatibility. |
195 | | -
|
196 | | - **kwargs: Keyword arguments. Fed directly to the iRODSSession |
197 | | - constructor.""" |
198 | | - |
199 | | - env_file = env_filename_from_keyword_args(kwargs) |
200 | | - session = iRODSSession(irods_env_file=env_file, **kwargs) |
201 | | - if test_server_version: |
202 | | - connected_version = get_server_version_for_test(session, curtail_length=3) |
203 | | - advertised_version = IRODS_VERSION[:3] |
204 | | - if connected_version > advertised_version: |
205 | | - msg = ( |
206 | | - "Connected server is {connected_version}, " |
207 | | - "but this python-irodsclient advertises compatibility up to {advertised_version}." |
208 | | - ).format(**locals()) |
209 | | - raise iRODS_Server_Too_Recent(msg) |
210 | | - |
211 | | - return session |
212 | | - |
213 | | - |
214 | | -def home_collection(session): |
215 | | - """Return a string value for the given session's home collection.""" |
216 | | - return "/{0.zone}/home/{0.username}".format(session) |
| 170 | +make_session.__doc__ = re.sub( |
| 171 | + r"(test_server_version\s*)=\s*\w+", r"\1 = True", _irods_helpers_make_session.__doc__ |
| 172 | +) |
217 | 173 |
|
218 | 174 |
|
219 | 175 | def make_object(session, path, content=None, **options): |
|
0 commit comments