Here are the examples of the python api mock.sentinel.db_name taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Example 1
def test_initialize_library():
self = create_autospec(Arctic)
self._conn = create_autospec(MongoClient)
lib = create_autospec(ArcticLibraryBinding)
lib.database_name = sentinel.db_name
lib.get_quota.return_value = None
lib_type = Mock()
with patch.dict('arctic.arctic.LIBRARY_TYPES', {sentinel.lib_type: lib_type}), \
patch('arctic.arctic.ArcticLibraryBinding', return_value=lib, autospec=True) as ML:
Arctic.initialize_library(self, sentinel.lib_name, sentinel.lib_type, thing=sentinel.thing)
assert ML.call_args_list == [call(self, sentinel.lib_name)]
assert ML.return_value.set_library_type.call_args_list == [call(sentinel.lib_type)]
assert ML.return_value.set_quota.call_args_list == [call(10 * 1024 * 1024 * 1024)]
assert lib_type.initialize_library.call_args_list == [call(ML.return_value, thing=sentinel.thing)]
3
Example 2
Project: arctic Source File: test_arctic.py
def test_initialize_library_too_many_ns():
self = create_autospec(Arctic)
self._conn = create_autospec(MongoClient)
lib = create_autospec(ArcticLibraryBinding)
lib.database_name = sentinel.db_name
self._conn.__getitem__.return_value.collection_names.return_value = [x for x in six.moves.xrange(3001)]
lib_type = Mock()
with pytest.raises(ArcticException) as e:
with patch.dict('arctic.arctic.LIBRARY_TYPES', {sentinel.lib_type: lib_type}), \
patch('arctic.arctic.ArcticLibraryBinding', return_value=lib, autospec=True) as ML:
Arctic.initialize_library(self, sentinel.lib_name, sentinel.lib_type, thing=sentinel.thing)
assert self._conn.__getitem__.call_args_list == [call(sentinel.db_name),
call(sentinel.db_name)]
assert lib_type.initialize_library.call_count == 0
assert 'Too many namespaces 3001, not creating: sentinel.lib_name' in str(e)