19
19
def test_arctic_lazy_init ():
20
20
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ) as mc , \
21
21
patch ('arctic.arctic.mongo_retry' , side_effect = lambda x : x , autospec = True ), \
22
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
22
23
patch ('arctic.arctic.get_auth' , autospec = True ) as ga :
23
24
store = Arctic ('cluster' )
24
25
assert not mc .called
@@ -30,6 +31,7 @@ def test_arctic_lazy_init():
30
31
def test_arctic_lazy_init_ssl_true ():
31
32
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ) as mc , \
32
33
patch ('arctic.arctic.mongo_retry' , side_effect = lambda x : x , autospec = True ), \
34
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
33
35
patch ('arctic.arctic.get_auth' , autospec = True ) as ga :
34
36
store = Arctic ('cluster' , ssl = True )
35
37
assert not mc .called
@@ -48,6 +50,7 @@ def test_arctic_lazy_init_ssl_true():
48
50
def test_connection_passed_warning_raised ():
49
51
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ), \
50
52
patch ('arctic.arctic.mongo_retry' , side_effect = lambda x : x , autospec = True ), \
53
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
51
54
patch ('arctic.arctic.get_auth' , autospec = True ), \
52
55
patch ('arctic.arctic.logger' ) as lg :
53
56
magic_mock = MagicMock (nodes = {("host" , "port" )})
@@ -62,7 +65,8 @@ def test_connection_passed_warning_raised():
62
65
def test_arctic_auth ():
63
66
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ), \
64
67
patch ('arctic.arctic.mongo_retry' , autospec = True ), \
65
- patch ('arctic.arctic.get_auth' , autospec = True ) as ga :
68
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
69
+ patch ('arctic.arctic.get_auth' , autospec = True ) as ga :
66
70
ga .return_value = Credential ('db' , 'admin_user' , 'admin_pass' )
67
71
store = Arctic ('cluster' )
68
72
# do something to trigger lazy arctic init
@@ -86,7 +90,8 @@ def test_arctic_auth():
86
90
def test_arctic_auth_custom_app_name ():
87
91
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ), \
88
92
patch ('arctic.arctic.mongo_retry' , autospec = True ), \
89
- patch ('arctic.arctic.get_auth' , autospec = True ) as ga :
93
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
94
+ patch ('arctic.arctic.get_auth' , autospec = True ) as ga :
90
95
ga .return_value = Credential ('db' , 'admin_user' , 'admin_pass' )
91
96
store = Arctic ('cluster' , app_name = sentinel .app_name )
92
97
# do something to trigger lazy arctic init
@@ -108,7 +113,8 @@ def test_arctic_auth_custom_app_name():
108
113
def test_arctic_connect_hostname ():
109
114
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ) as mc , \
110
115
patch ('arctic.arctic.mongo_retry' , autospec = True ) as ar , \
111
- patch ('arctic.arctic.get_mongodb_uri' , autospec = True ) as gmu :
116
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
117
+ patch ('arctic.arctic.get_mongodb_uri' , autospec = True ) as gmu :
112
118
store = Arctic ('hostname' , socketTimeoutMS = sentinel .socket_timeout ,
113
119
connectTimeoutMS = sentinel .connect_timeout ,
114
120
serverSelectionTimeoutMS = sentinel .select_timeout )
@@ -124,6 +130,7 @@ def test_arctic_connect_with_environment_name():
124
130
with patch ('pymongo.MongoClient' , return_value = MagicMock (), autospec = True ) as mc , \
125
131
patch ('arctic.arctic.mongo_retry' , autospec = True ) as ar , \
126
132
patch ('arctic.arctic.get_auth' , autospec = True ), \
133
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ), \
127
134
patch ('arctic.arctic.get_mongodb_uri' ) as gmfe :
128
135
store = Arctic ('live' , socketTimeoutMS = sentinel .socket_timeout ,
129
136
connectTimeoutMS = sentinel .connect_timeout ,
@@ -453,7 +460,8 @@ def flaky_auth(*args, **kwargs):
453
460
454
461
def test_reset ():
455
462
c = MagicMock ()
456
- with patch ('pymongo.MongoClient' , return_value = c , autospec = True ) as mc :
463
+ with patch ('pymongo.MongoClient' , return_value = c , autospec = True ) as mc , \
464
+ patch ('arctic._cache.Cache._is_not_expired' , return_value = True ):
457
465
store = Arctic ('hostname' )
458
466
# do something to trigger lazy arctic init
459
467
store .list_libraries ()
0 commit comments