11import datajoint as dj
22from packaging import version
33import os
4+ import minio
5+ import urllib3
6+ import certifi
7+ import shutil
48import pytest
5- from . import PREFIX , schema , schema_simple , schema_advanced
9+ import networkx as nx
10+ import json
11+ from pathlib import Path
12+ import tempfile
13+ from datajoint import errors
14+ from datajoint .errors import ADAPTED_TYPE_SWITCH , FILEPATH_FEATURE_SWITCH
15+ from . import (
16+ PREFIX ,
17+ CONN_INFO ,
18+ S3_CONN_INFO ,
19+ schema ,
20+ schema_simple ,
21+ schema_advanced ,
22+ schema_adapted ,
23+ )
624
7- namespace = locals ()
25+
26+ @pytest .fixture (scope = "session" )
27+ def monkeysession ():
28+ with pytest .MonkeyPatch .context () as mp :
29+ yield mp
30+
31+
32+ @pytest .fixture (scope = "module" )
33+ def monkeymodule ():
34+ with pytest .MonkeyPatch .context () as mp :
35+ yield mp
836
937
1038@pytest .fixture (scope = "session" )
@@ -64,11 +92,12 @@ def connection_test(connection_root):
6492 connection .close ()
6593
6694
67- @pytest .fixture ( scope = "module" )
95+ @pytest .fixture
6896def schema_any (connection_test ):
6997 schema_any = dj .Schema (
70- PREFIX + "_test1" , schema .__dict__ , connection = connection_test
98+ PREFIX + "_test1" , schema .LOCALS_ANY , connection = connection_test
7199 )
100+ assert schema .LOCALS_ANY , "LOCALS_ANY is empty"
72101 schema_any (schema .TTest )
73102 schema_any (schema .TTest2 )
74103 schema_any (schema .TTest3 )
@@ -109,10 +138,10 @@ def schema_any(connection_test):
109138 schema_any .drop ()
110139
111140
112- @pytest .fixture ( scope = "module" )
141+ @pytest .fixture
113142def schema_simp (connection_test ):
114143 schema = dj .Schema (
115- PREFIX + "_relational" , schema_simple .__dict__ , connection = connection_test
144+ PREFIX + "_relational" , schema_simple .LOCALS_SIMPLE , connection = connection_test
116145 )
117146 schema (schema_simple .IJ )
118147 schema (schema_simple .JI )
@@ -136,10 +165,12 @@ def schema_simp(connection_test):
136165 schema .drop ()
137166
138167
139- @pytest .fixture ( scope = "module" )
168+ @pytest .fixture
140169def schema_adv (connection_test ):
141170 schema = dj .Schema (
142- PREFIX + "_advanced" , schema_advanced .__dict__ , connection = connection_test
171+ PREFIX + "_advanced" ,
172+ schema_advanced .LOCALS_ADVANCED ,
173+ connection = connection_test ,
143174 )
144175 schema (schema_advanced .Person )
145176 schema (schema_advanced .Parent )
@@ -152,3 +183,30 @@ def schema_adv(connection_test):
152183 schema (schema_advanced .GlobalSynapse )
153184 yield schema
154185 schema .drop ()
186+
187+
188+ @pytest .fixture
189+ def httpClient ():
190+ # Initialize httpClient with relevant timeout.
191+ httpClient = urllib3 .PoolManager (
192+ timeout = 30 ,
193+ cert_reqs = "CERT_REQUIRED" ,
194+ ca_certs = certifi .where (),
195+ retries = urllib3 .Retry (
196+ total = 3 , backoff_factor = 0.2 , status_forcelist = [500 , 502 , 503 , 504 ]
197+ ),
198+ )
199+ yield httpClient
200+
201+
202+ @pytest .fixture
203+ def minioClient ():
204+ # Initialize minioClient with an endpoint and access/secret keys.
205+ minioClient = minio .Minio (
206+ S3_CONN_INFO ["endpoint" ],
207+ access_key = S3_CONN_INFO ["access_key" ],
208+ secret_key = S3_CONN_INFO ["secret_key" ],
209+ secure = True ,
210+ http_client = httpClient ,
211+ )
212+ yield minioClient
0 commit comments