# Path: sacred/observers/mongo.py
# def parse_mongo_db_arg(mongo_db):
#     g = re.match(get_pattern(), mongo_db).groupdict()
#     if g is None:
#         raise ValueError(
#             'mongo_db argument must have the form "db_name" '
#             'or "host:port[:db_name]" but was {}'.format(mongo_db)
#         )
# 
#     kwargs = {}
#     if g["host1"]:
#         kwargs["url"] = "{}:{}".format(g["host1"], g["port1"])
#     elif g["host2"]:
#         kwargs["url"] = "{}:{}".format(g["host2"], g["port2"])
# 
#     if g["priority"] is not None:
#         kwargs["priority"] = int(g["priority"])
# 
#     for p in ["db_name", "collection", "overwrite"]:
#         if g[p] is not None:
#             kwargs[p] = g[p]
# 
#     return kwargs
# 
# DEFAULT_MONGO_PRIORITY = 30


import pytest
from sacred.observers.mongo import parse_mongo_db_arg, DEFAULT_MONGO_PRIORITY
        "db_name": "bar",
    }

    assert 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_hostname_dbname_collection_name():
    assert parse_mongo_db_arg("localhost:28017:foo.bar") == {
        "url": "localhost:28017",
        "db_name": "foo",
        "collection": "bar",
    }

    assert parse_mongo_db_arg("www.mymongo.db:28017:bar.baz") == {
        "url": "www.mymongo.db:28017",
        "db_name": "bar",
        "collection": "baz",
    }

    assert 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_priority():

# Path: sacred/observers/mongo.py
# def parse_mongo_db_arg(mongo_db):
#     g = re.match(get_pattern(), mongo_db).groupdict()
#     if g is None:
#         raise ValueError(
#             'mongo_db argument must have the form "db_name" '
#             'or "host:port[:db_name]" but was {}'.format(mongo_db)
#         )
# 
#     kwargs = {}
#     if g["host1"]:
#         kwargs["url"] = "{}:{}".format(g["host1"], g["port1"])
#     elif g["host2"]:
#         kwargs["url"] = "{}:{}".format(g["host2"], g["port2"])
# 
#     if g["priority"] is not None:
#         kwargs["priority"] = int(g["priority"])
# 
#     for p in ["db_name", "collection", "overwrite"]:
#         if g[p] is not None:
#             kwargs[p] = g[p]
# 
#     return kwargs
# 
# DEFAULT_MONGO_PRIORITY = 30


# Path: tests/test_observers/test_mongo_option.py
import pytest
from sacred.observers.mongo import parse_mongo_db_arg, DEFAULT_MONGO_PRIORITY

        "db_name": "bar",
    }

    assert 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_hostname_dbname_collection_name():
    assert parse_mongo_db_arg("localhost:28017:foo.bar") == {
        "url": "localhost:28017",
        "db_name": "foo",
        "collection": "bar",
    }

    assert parse_mongo_db_arg("www.mymongo.db:28017:bar.baz") == {
        "url": "www.mymongo.db:28017",
        "db_name": "bar",
        "collection": "baz",
    }

    assert 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_priority():

    assert parse_mongo_db_arg("localhost:28017:foo.bar!17") == {