示例#1
0
def test_create_conflict():
    manager = ResourceManager()
    manager.inventory = {
        "already-exists": {
            "name": "already-exists",
            "type": "shell"
        }
    }
    with pytest.raises(ResourceAlreadyExistsError):
        manager.create("already-exists", "type-doesnt-matter")
示例#2
0
def test_create_includes_config(tmpdir):
    tmpdir = str(tmpdir)
    manager = ResourceManager(op.join(tmpdir, "inventory.yml"))
    # We load items from the config.
    config_file = op.join(tmpdir, "reproman.cfg")
    with open(config_file, "w") as cfh:
        cfh.write("[ssh]\nhost = myhost\n")
    config = ConfigManager(filenames=[config_file], load_default=False)
    with patch.object(manager, "config_manager", config):
        with patch.object(manager, "factory") as factory:
            manager.create("myssh", "ssh")
            factory.assert_called_with({
                "host": "myhost",
                "name": "myssh",
                "type": "ssh"
            })
示例#3
0
 def fixture(tmpdir_factory):
     path = str(tmpdir_factory.mktemp("rmanager").join("inventory"))
     manager = ResourceManager(path)
     for name, kwargs in resources.items():
         manager.create(name, **kwargs)
     return manager