Пример #1
0
def test_resolve_multi_args():
    """Resolve multiple paths"""

    r = cpenv.Resolver(cpenv.get_repos())

    resolved = r.resolve(["testmod", "testmodb", "testmodc"])
    assert len(resolved) == 3
Пример #2
0
def test_resolve_relative():
    """Resolve module from relative path"""

    with cwd(data_path("not_home")):
        r = cpenv.Resolver(cpenv.get_repos())
        resolved = r.resolve(["relmod"])

    assert resolved[0].path == data_path("not_home", "relmod")
Пример #3
0
def test_redirect_resolver_from_file():
    """Resolve module from file, parent folder has .cpenv file"""

    expected_paths = [
        data_path("home", "modules", "testmod"),
        data_path("modules", "testmodb"),
        data_path("home", "modules", "testmodc"),
    ]

    r = cpenv.Resolver(cpenv.get_repos())
    resolved = r.resolve([
        data_path("not_home", "project", "sequence", "shot", "shot_file.txt")
    ])

    assert resolved[0].path == expected_paths[0]
    assert resolved[1].path == expected_paths[1]
    assert resolved[2].path == expected_paths[2]
Пример #4
0
def test_resolve_module_on_path():
    """Resolve module in CPENV_MODULES path"""

    r = cpenv.Resolver(cpenv.get_repos())

    # Test resolve global module
    resolved = r.resolve(["testmodb"])
    assert resolved[0].path == data_path("modules", "testmodb")

    # Test resolve module in home, should take precedence over global
    # module of the same name
    resolved = r.resolve(["testmod"])
    assert resolved[0].path == data_path("home", "modules", "testmod")

    # Test resoluve module in CPENV_HOME/modules
    resolved = r.resolve(["testmodc"])
    assert resolved[0].path == data_path("home", "modules", "testmodc")

    # Test global module does not exist
    with pytest.raises(cpenv.ResolveError):
        r.resolve(["testmod", "does_not_exist"])
Пример #5
0
def test_resolve_home():
    """Resolve module in CPENV_HOME"""

    r = cpenv.Resolver(cpenv.get_repos())
    resolved = r.resolve(["testmod"])
    assert resolved[0].path == data_path("home", "modules", "testmod")
Пример #6
0
def test_multi_module_does_not_exist():
    """Raise cpenv.ResolveError when a module does not exist"""

    with pytest.raises(cpenv.ResolveError):
        r = cpenv.Resolver(cpenv.get_repos())
        r.resolve(["testmod", "testmodb", "does_not_exist"])
Пример #7
0
def test_nonexistant_module():
    """Raise cpenv.ResolveError when module does not exist"""

    with pytest.raises(cpenv.ResolveError):
        r = cpenv.Resolver(cpenv.get_repos())
        r.resolve(["testmod", "does_not_exist"])