示例#1
0
 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
示例#2
0
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)
示例#5
0
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', '')
示例#6
0
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)
示例#7
0
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', '')
示例#8
0
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'}
示例#9
0
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'}
示例#10
0
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', '')
示例#11
0
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"
    }
示例#12
0
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}
示例#13
0
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",
    }
示例#14
0
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,
        }
示例#15
0
def test_parse_mongo_db_arg():
    assert MongoDbOption.parse_mongo_db_arg("foo") == {"db_name": "foo"}
示例#16
0
def test_parse_mongo_db_arg():
    assert MongoDbOption.parse_mongo_db_arg('foo') == {'db_name': 'foo'}
示例#17
0
def test_parse_mongo_db_arg_collection():
    kwargs = MongoDbOption.parse_mongo_db_arg('foo.bar')
    assert kwargs == {'db_name': 'foo', 'collection': 'bar'}
示例#18
0
def test_parse_mongo_db_arg():
    assert MongoDbOption.parse_mongo_db_arg("foo") == ("localhost:27017", "foo", "")
示例#19
0
def test_parse_mongo_db_arg():
    assert MongoDbOption.parse_mongo_db_arg('foo') == ('localhost:27017',
                                                       'foo', None, None,
                                                       DEFAULT_MONGO_PRIORITY)
示例#20
0
def test_parse_mongo_db_arg():
    assert MongoDbOption.parse_mongo_db_arg('foo') == ('localhost:27017',
                                                       'foo', '')
示例#21
0
def test_parse_mongo_db_arg_collection():
    assert MongoDbOption.parse_mongo_db_arg('foo.bar') == ('localhost:27017',
                                                           'foo', 'bar')
示例#22
0
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", "")
示例#23
0
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)
示例#25
0
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")
示例#26
0
def test_parse_mongo_db_arg_collection():
    kwargs = MongoDbOption.parse_mongo_db_arg("foo.bar")
    assert kwargs == {"db_name": "foo", "collection": "bar"}
示例#27
0
def test_parse_mongo_db_arg_collection():
    assert MongoDbOption.parse_mongo_db_arg('foo.bar') == ('localhost:27017',
                                                           'foo', 'bar')
示例#28
0
def test_parse_mongo_db_arg():
    assert MongoDbOption.parse_mongo_db_arg('foo') == ('localhost:27017',
                                                       'foo', '')