5
5
6
6
from ...util import run_as_main
7
7
8
+ from arctic .scripts .arctic_init_library import Arctic as ar
9
+
8
10
9
11
def test_init_library ():
10
12
# Create the user agains the current mongo database
11
13
with patch ('pymongo.MongoClient' ) as MongoClient , \
12
14
patch ('arctic.scripts.arctic_init_library.logger' , autospec = True ) as logger , \
13
- patch ('arctic.scripts.arctic_init_library.Arctic' , autospec = True ) as Arctic , \
15
+ patch ('arctic.scripts.arctic_init_library.Arctic' , spec = ar ) as Arctic , \
14
16
patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' , autospec = True ) as get_mongodb_uri , \
15
17
patch ('arctic.scripts.arctic_init_library.do_db_auth' , autospec = True ) as do_db_auth :
16
18
run_as_main (mil .main , '--host' , 'hostname' , '--library' , 'arctic_user.library' , '--type' , 'VersionStore' )
@@ -26,10 +28,10 @@ def test_init_library():
26
28
def test_init_library_no_admin ():
27
29
# Create the user agains the current mongo database
28
30
with patch ('pymongo.MongoClient' ) as MongoClient , \
29
- patch ('arctic.scripts.arctic_init_library.logger' ), \
30
- patch ('arctic.scripts.arctic_init_library.Arctic' ) as Arctic , \
31
- patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' ) as get_mongodb_uri , \
32
- patch ('arctic.scripts.arctic_init_library.do_db_auth' ) as do_db_auth :
31
+ patch ('arctic.scripts.arctic_init_library.logger' , autospec = True ), \
32
+ patch ('arctic.scripts.arctic_init_library.Arctic' , spec = ar ) as Arctic , \
33
+ patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' , autospec = True ) as get_mongodb_uri , \
34
+ patch ('arctic.scripts.arctic_init_library.do_db_auth' , autospec = True ) as do_db_auth :
33
35
run_as_main (mil .main , '--host' , 'hostname' , '--library' , 'arctic_user.library' , '--type' , 'VersionStore' )
34
36
35
37
get_mongodb_uri .assert_called_once_with ('hostname' )
@@ -41,10 +43,10 @@ def test_init_library_no_admin():
41
43
def test_init_library_hashed ():
42
44
# Create the user agains the current mongo database
43
45
with patch ('pymongo.MongoClient' ) as MongoClient , \
44
- patch ('arctic.scripts.arctic_init_library.logger' ) as logger , \
45
- patch ('arctic.scripts.arctic_init_library.Arctic' ) as Arctic , \
46
- patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' ) as get_mongodb_uri , \
47
- patch ('arctic.scripts.arctic_init_library.do_db_auth' ) as do_db_auth :
46
+ patch ('arctic.scripts.arctic_init_library.logger' , autospec = True ) as logger , \
47
+ patch ('arctic.scripts.arctic_init_library.Arctic' , spec = ar ) as Arctic , \
48
+ patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' , autospec = True ) as get_mongodb_uri , \
49
+ patch ('arctic.scripts.arctic_init_library.do_db_auth' , autospec = True ) as do_db_auth :
48
50
run_as_main (mil .main , '--host' , 'hostname' , '--library' , 'arctic_user.library' , '--type' , 'VersionStore' , '--hashed' )
49
51
50
52
get_mongodb_uri .assert_called_once_with ('hostname' )
@@ -57,10 +59,10 @@ def test_init_library_hashed():
57
59
58
60
def test_init_library_no_admin_no_user_creds ():
59
61
with patch ('pymongo.MongoClient' ) as MongoClient , \
60
- patch ('arctic.scripts.arctic_init_library.logger' ) as logger , \
61
- patch ('arctic.scripts.arctic_init_library.Arctic' ) as Arctic , \
62
- patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' ) as get_mongodb_uri , \
63
- patch ('arctic.scripts.arctic_init_library.do_db_auth' , return_value = False ) as do_db_auth :
62
+ patch ('arctic.scripts.arctic_init_library.logger' , autospec = True ) as logger , \
63
+ patch ('arctic.scripts.arctic_init_library.Arctic' , spec = ar ) as Arctic , \
64
+ patch ('arctic.scripts.arctic_init_library.get_mongodb_uri' , autospec = True ) as get_mongodb_uri , \
65
+ patch ('arctic.scripts.arctic_init_library.do_db_auth' , return_value = False , autospec = True ) as do_db_auth :
64
66
65
67
MongoClient .return_value ['arctic_user' ].authenticate .return_value = False
66
68
run_as_main (mil .main , '--host' , 'hostname' , '--library' , 'arctic_user.library' , '--type' , 'VersionStore' )
0 commit comments