Exemplo n.º 1
0
def test_prepare_namespace():
    namespaces = utils.prepare_namespace("com")
    assert namespaces == ["com"]
    namespaces = utils.prepare_namespace("com.blue_yonder")
    assert namespaces == ["com", "com.blue_yonder"]
    with pytest.raises(RuntimeError):
        utils.prepare_namespace("com.blue-yonder")
Exemplo n.º 2
0
def test_prepare_namespace():
    namespaces = utils.prepare_namespace("com")
    assert namespaces == ["com"]
    namespaces = utils.prepare_namespace("com.blue_yonder")
    assert namespaces == ["com", "com.blue_yonder"]
    with pytest.raises(InvalidIdentifier):
        utils.prepare_namespace("com.blue-yonder")
Exemplo n.º 3
0
def test_prepare_namespace():
    namespaces = utils.prepare_namespace("com")
    assert namespaces == ["com"]
    namespaces = utils.prepare_namespace("com.blue_yonder")
    assert namespaces == ["com", "com.blue_yonder"]
    with pytest.raises(RuntimeError):
        utils.prepare_namespace("com.blue-yonder")
Exemplo n.º 4
0
def test_prepare_namespace():
    namespaces = utils.prepare_namespace("com")
    assert namespaces == ["com"]
    namespaces = utils.prepare_namespace("com.blue_yonder")
    assert namespaces == ["com", "com.blue_yonder"]
    with pytest.raises(InvalidIdentifier):
        utils.prepare_namespace("com.blue-yonder")
Exemplo n.º 5
0
def test_add_namespace():
    args = ["project", "-p", "package", "--with-namespace", "com.blue_yonder"]
    opts = cli.parse_args(args)
    opts['namespace'] = utils.prepare_namespace(opts['namespace'])
    struct = {"project": {"package": {"file1": "Content"}}}
    ns_struct = structure.add_namespace(opts, struct)
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_struct["project"].keys())
    assert {"blue_yonder",
            "__init__.py"} == set(ns_struct["project"]["com"].keys())
    assert "package" in list(ns_struct["project"]["com"]["blue_yonder"].keys())
def test_add_namespace():
    args = ["project", "-p", "package", "--namespace", "com.blue_yonder"]
    opts = parse_args(args)
    opts['namespace'] = prepare_namespace(opts['namespace'])
    struct = {"project": {"src": {"package": {"file1": "Content"}}}}
    ns_struct, _ = add_namespace(struct, opts)
    ns_pkg_struct = ns_struct["project"]["src"]
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_pkg_struct.keys())
    assert {"blue_yonder", "__init__.py"} == set(ns_pkg_struct["com"].keys())
    assert "package" in list(ns_pkg_struct["com"]["blue_yonder"].keys())
Exemplo n.º 7
0
def test_add_namespace():
    args = ["project",
            "-p", "package",
            "--with-namespace", "com.blue_yonder"]
    opts = cli.parse_args(args)
    opts['namespace'] = utils.prepare_namespace(opts['namespace'])
    struct = {"project": {"package": {"file1": "Content"}}}
    ns_struct = structure.add_namespace(opts, struct)
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_struct["project"].keys())
    assert {"blue_yonder", "__init__.py"} == set(
        ns_struct["project"]["com"].keys())
    assert "package" in list(ns_struct["project"]["com"]["blue_yonder"].keys())
Exemplo n.º 8
0
def test_add_namespace():
    args = ["project",
            "-p", "package",
            "--namespace", "com.blue_yonder"]
    opts = parse_args(args)
    opts['namespace'] = prepare_namespace(opts['namespace'])
    struct = {"project": {"src": {"package": {"file1": "Content"}}}}
    ns_struct, _ = add_namespace(struct, opts)
    ns_pkg_struct = ns_struct["project"]["src"]
    assert ["project"] == list(ns_struct.keys())
    assert "package" not in list(ns_struct.keys())
    assert ["com"] == list(ns_pkg_struct.keys())
    assert {"blue_yonder", "__init__.py"} == set(ns_pkg_struct["com"].keys())
    assert "package" in list(ns_pkg_struct["com"]["blue_yonder"].keys())