Skip to content

Commit 9a0fc60

Browse files
Merge pull request pandas-dev#23 from manahl/arctic_init_library_improvement
Simplify arctic_init_library to not require the 'arctic_' prefix.
2 parents feffebe + 2f25f4c commit 9a0fc60

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

arctic/scripts/arctic_init_library.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ def main():
3232

3333
opts = parser.parse_args()
3434

35-
if not opts.library or '.' not in opts.library \
36-
or not opts.library.startswith('arctic'):
37-
parser.error('Must specify the full path of the library e.g. arctic_jblackburn.library!')
35+
if not opts.library or '.' not in opts.library:
36+
parser.error('Must specify the full path of the library e.g. user.library!')
3837
db_name, _ = ArcticLibraryBinding._parse_db_lib(opts.library)
3938

4039
print "Initializing: %s on mongo %s" % (opts.library, opts.host)

tests/integration/scripts/test_initialize_library.py

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ def test_init_library(mongo_host):
2121
assert store['user.library'].read('key').data == {'a': 'b'}
2222

2323

24+
def test_init_library_no_arctic_prefix(mongo_host):
25+
# Create the user agains the current mongo database
26+
with patch('arctic.scripts.arctic_init_library.do_db_auth', return_value=True), \
27+
patch('pymongo.database.Database.authenticate', return_value=True):
28+
run_as_main(mil.main, '--host', mongo_host, '--library', 'user.library')
29+
30+
# Should be able to write something to the library now
31+
store = Arctic(mongo_host)
32+
assert store['user.library']._arctic_lib.get_library_metadata('QUOTA') == 10240 * 1024 * 1024
33+
store['user.library'].write('key', {'a': 'b'})
34+
assert store['user.library'].read('key').data == {'a': 'b'}
35+
36+
2437
def test_init_library_quota(mongo_host):
2538
# Create the user agains the current mongo database
2639
with patch('arctic.scripts.arctic_init_library.do_db_auth', return_value=True), \

tests/unit/scripts/test_initialize_library.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,12 @@ def test_init_library_no_admin_no_user_creds():
7171

7272

7373
def test_bad_library_name():
74-
with pytest.raises(Exception):
75-
with patch('argparse.ArgumentParser.error', side_effect=Exception) as error:
76-
run_as_main(mil.main, '--library', 'user.library')
77-
error.assert_called_once_with('Must specify the full path of the library e.g. arctic_jblackburn.library!')
78-
7974
with pytest.raises(Exception):
8075
with patch('argparse.ArgumentParser.error', side_effect=Exception) as error:
8176
run_as_main(mil.main, '--library', 'arctic_jblackburn')
82-
error.assert_called_once_with('Must specify the full path of the library e.g. arctic_jblackburn.library!')
77+
error.assert_called_once_with('Must specify the full path of the library e.g. user.library!')
8378

8479
with pytest.raises(Exception):
8580
with patch('argparse.ArgumentParser.error', side_effect=Exception) as error:
8681
run_as_main(mil.main)
87-
error.assert_called_once_with('Must specify the full path of the library e.g. arctic_jblackburn.library!')
82+
error.assert_called_once_with('Must specify the full path of the library e.g. user.library!')

0 commit comments

Comments
 (0)