def _option_hook(self, options): mongo_opt = options.get(MongoDbOption.get_flag()) if mongo_opt is not None: fake_run = FakeRun() MongoDbOption.apply(mongo_opt, fake_run) self.mongo_observer = fake_run.observers[0] else: self.mongo_observer = None
def test_parse_mongo_db_arg_hostname_dbname_collection_name(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017:foo.bar') == \ ('localhost:28017', 'foo', 'bar') assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017:bar.baz') ==\ ('www.mymongo.db:28017', 'bar', 'baz') assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017:baz.foo') == \ ('123.45.67.89:27017', 'baz', 'foo')
def test_parse_mongo_db_arg_hostname_dbname_collection_name(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017:foo.bar') == \ ('localhost:28017', 'foo', 'bar', DEFAULT_MONGO_PRIORITY) assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017:bar.baz') ==\ ('www.mymongo.db:28017', 'bar', 'baz', DEFAULT_MONGO_PRIORITY) assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017:baz.foo') == \ ('123.45.67.89:27017', 'baz', 'foo', DEFAULT_MONGO_PRIORITY)
def test_parse_mongo_db_arg_priority(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017:foo.bar!17') == \ ('localhost:28017', 'foo', 'bar', 17) assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017:bar.baz!2') ==\ ('www.mymongo.db:28017', 'bar', 'baz', 2) assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017:baz.foo!-123') == \ ('123.45.67.89:27017', 'baz', 'foo', -123)
def test_parse_mongo_db_arg_hostname(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017') == \ ('localhost:28017', 'sacred', '') assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017') == \ ('www.mymongo.db:28017', 'sacred', '') assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017') == \ ('123.45.67.89:27017', 'sacred', '')
def test_parse_mongo_db_arg_hostname(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017') == \ ('localhost:28017', 'sacred', None, None, DEFAULT_MONGO_PRIORITY) assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017') == \ ('www.mymongo.db:28017', 'sacred', None, None, DEFAULT_MONGO_PRIORITY) assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017') == \ ('123.45.67.89:27017', 'sacred', None, None, DEFAULT_MONGO_PRIORITY)
def test_parse_mongo_db_arg_hostname_dbname(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017:foo') == \ ('localhost:28017', 'foo', '') assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017:bar') == \ ('www.mymongo.db:28017', 'bar', '') assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017:baz') == \ ('123.45.67.89:27017', 'baz', '')
def test_parse_mongo_db_arg_hostname(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017') == \ {'url': 'localhost:28017'} assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017') == \ {'url': 'www.mymongo.db:28017'} assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017') == \ {'url': '123.45.67.89:27017'}
def test_parse_mongo_db_arg_hostname_dbname_collection_name(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017:foo.bar') == \ {'url': 'localhost:28017', 'db_name': 'foo', 'collection': 'bar'} assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017:bar.baz') ==\ {'url': 'www.mymongo.db:28017', 'db_name': 'bar', 'collection': 'baz'} assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017:baz.foo') == \ {'url': '123.45.67.89:27017', 'db_name': 'baz', 'collection': 'foo'}
def test_parse_mongo_db_arg_hostname(): assert MongoDbOption.parse_mongo_db_arg("localhost:28017") == { "url": "localhost:28017" } assert MongoDbOption.parse_mongo_db_arg("www.mymongo.db:28017") == { "url": "www.mymongo.db:28017" } assert MongoDbOption.parse_mongo_db_arg("123.45.67.89:27017") == { "url": "123.45.67.89:27017" }
def test_parse_mongo_db_arg_priority(): assert MongoDbOption.parse_mongo_db_arg('localhost:28017:foo.bar!17') == \ {'url': 'localhost:28017', 'db_name': 'foo', 'collection': 'bar', 'priority': 17} assert MongoDbOption.parse_mongo_db_arg('www.mymongo.db:28017:bar.baz!2') ==\ {'url': 'www.mymongo.db:28017', 'db_name': 'bar', 'collection': 'baz', 'priority': 2} assert MongoDbOption.parse_mongo_db_arg('123.45.67.89:27017:baz.foo!-123') == \ {'url': '123.45.67.89:27017', 'db_name': 'baz', 'collection': 'foo', 'priority': -123}
def test_parse_mongo_db_arg_hostname_dbname(): assert MongoDbOption.parse_mongo_db_arg("localhost:28017:foo") == { "url": "localhost:28017", "db_name": "foo", } assert MongoDbOption.parse_mongo_db_arg("www.mymongo.db:28017:bar") == { "url": "www.mymongo.db:28017", "db_name": "bar", } assert MongoDbOption.parse_mongo_db_arg("123.45.67.89:27017:baz") == { "url": "123.45.67.89:27017", "db_name": "baz", }
def test_parse_mongo_db_arg_priority(): assert MongoDbOption.parse_mongo_db_arg("localhost:28017:foo.bar!17") == { "url": "localhost:28017", "db_name": "foo", "collection": "bar", "priority": 17, } assert MongoDbOption.parse_mongo_db_arg( "www.mymongo.db:28017:bar.baz!2") == { "url": "www.mymongo.db:28017", "db_name": "bar", "collection": "baz", "priority": 2, } assert MongoDbOption.parse_mongo_db_arg( "123.45.67.89:27017:baz.foo!-123") == { "url": "123.45.67.89:27017", "db_name": "baz", "collection": "foo", "priority": -123, }
def test_parse_mongo_db_arg(): assert MongoDbOption.parse_mongo_db_arg("foo") == {"db_name": "foo"}
def test_parse_mongo_db_arg(): assert MongoDbOption.parse_mongo_db_arg('foo') == {'db_name': 'foo'}
def test_parse_mongo_db_arg_collection(): kwargs = MongoDbOption.parse_mongo_db_arg('foo.bar') assert kwargs == {'db_name': 'foo', 'collection': 'bar'}
def test_parse_mongo_db_arg(): assert MongoDbOption.parse_mongo_db_arg("foo") == ("localhost:27017", "foo", "")
def test_parse_mongo_db_arg(): assert MongoDbOption.parse_mongo_db_arg('foo') == ('localhost:27017', 'foo', None, None, DEFAULT_MONGO_PRIORITY)
def test_parse_mongo_db_arg(): assert MongoDbOption.parse_mongo_db_arg('foo') == ('localhost:27017', 'foo', '')
def test_parse_mongo_db_arg_collection(): assert MongoDbOption.parse_mongo_db_arg('foo.bar') == ('localhost:27017', 'foo', 'bar')
def test_parse_mongo_db_arg_hostname(): assert MongoDbOption.parse_mongo_db_arg("localhost:28017") == ("localhost:28017", "sacred", "") assert MongoDbOption.parse_mongo_db_arg("www.mymongo.db:28017") == ("www.mymongo.db:28017", "sacred", "") assert MongoDbOption.parse_mongo_db_arg("123.45.67.89:27017") == ("123.45.67.89:27017", "sacred", "")
def test_parse_mongo_db_arg_collection(): assert MongoDbOption.parse_mongo_db_arg("foo.bar") == ("localhost:27017", "foo", "bar")
def test_parse_mongo_db_arg_collection(): assert MongoDbOption.parse_mongo_db_arg('foo.bar') == ( 'localhost:27017', 'foo', 'bar', DEFAULT_MONGO_PRIORITY)
def test_parse_mongo_db_arg_hostname_dbname_collection_name(): assert MongoDbOption.parse_mongo_db_arg("localhost:28017:foo.bar") == ("localhost:28017", "foo", "bar") assert MongoDbOption.parse_mongo_db_arg("www.mymongo.db:28017:bar.baz") == ("www.mymongo.db:28017", "bar", "baz") assert MongoDbOption.parse_mongo_db_arg("123.45.67.89:27017:baz.foo") == ("123.45.67.89:27017", "baz", "foo")
def test_parse_mongo_db_arg_collection(): kwargs = MongoDbOption.parse_mongo_db_arg("foo.bar") assert kwargs == {"db_name": "foo", "collection": "bar"}