Exemplo n.º 1
0
def path_volume_add_del_test(tmpdir):
  v = VolumeManager()
  assert v.setup()
  assert v.get_all_names() == []
  my_path = str(tmpdir.mkdir("bla"))
  no_path = str(tmpdir.join("hugo"))
  # ok
  vol = v.add_volume("My:" + my_path)
  assert vol
  assert v.get_all_names() == ['My']
  assert v.is_volume('MY')
  assert vol.is_setup
  assert vol.get_path() == my_path
  assert v.add_volume("foo:" + my_path)
  assert v.get_all_names() == ['My', 'foo']
  # duplicate path mapping
  assert not v.add_volume("foo:" + my_path)
  # duplicate path name
  assert not v.add_volume("my:" + no_path)
  # invalid path
  assert not v.add_volume("foo:" + no_path)
  # ok
  assert v.del_volume("my")
  assert not vol.is_setup
  assert v.get_all_names() == ['foo']
  # invalid name
  assert not v.del_volume("baz")
  # shutdown
  v.shutdown()
Exemplo n.º 2
0
def path_volume_add_del_test(tmpdir):
    v = VolumeManager()
    assert v.setup()
    assert v.get_all_names() == []
    my_path = str(tmpdir.mkdir("bla"))
    no_path = str(tmpdir.join("hugo"))
    # ok
    vol = v.add_volume("My:" + my_path)
    assert vol
    assert v.get_all_names() == ["My"]
    assert v.is_volume("MY")
    assert vol.is_setup
    assert vol.get_path() == my_path
    assert v.add_volume("foo:" + my_path)
    assert v.get_all_names() == ["My", "foo"]
    # duplicate path mapping
    assert not v.add_volume("foo:" + my_path)
    # duplicate path name
    assert not v.add_volume("my:" + no_path)
    # invalid path
    assert not v.add_volume("foo:" + no_path)
    # ok
    assert v.del_volume("my")
    assert not vol.is_setup
    assert v.get_all_names() == ["foo"]
    # invalid name
    assert not v.del_volume("baz")
    # shutdown
    v.shutdown()
Exemplo n.º 3
0
def path_volume_create_test(tmpdir):
    v = VolumeManager(str(tmpdir))
    assert v.setup()
    spec = "my:" + str(tmpdir) + "/bla"
    # dir does not exist -> can't create
    assert not v.add_volume(spec)
    # create
    assert v.add_volume(spec + "?create")
    # check
    assert tmpdir.join("bla").check(dir=1)
    # shutdown
    v.shutdown()
Exemplo n.º 4
0
def path_volume_create_test(tmpdir):
  v = VolumeManager(str(tmpdir))
  assert v.setup()
  spec = "my:" + str(tmpdir) + "/bla"
  # dir does not exist -> can't create
  assert not v.add_volume(spec)
  # create
  assert v.add_volume(spec + "?create")
  # check
  assert tmpdir.join("bla").check(dir=1)
  # shutdown
  v.shutdown()
Exemplo n.º 5
0
def path_volume_temp_test(tmpdir):
    v = VolumeManager(str(tmpdir))
    assert v.setup()
    spec = "my:" + str(tmpdir)
    # dir does exist -> no temp possible
    assert not v.add_volume(spec + "?temp")
    # create temp
    spec += "/bla"
    assert v.add_volume(spec + "?temp")
    # check that temp dir exists
    assert tmpdir.join("bla").check(dir=1)
    # shutdown
    v.shutdown()
    # now temp is gone
    assert not tmpdir.join("bla").check()
Exemplo n.º 6
0
def path_volume_temp_test(tmpdir):
  v = VolumeManager(str(tmpdir))
  assert v.setup()
  spec = "my:" + str(tmpdir)
  # dir does exist -> no temp possible
  assert not v.add_volume(spec + "?temp")
  # create temp
  spec += "/bla"
  assert v.add_volume(spec + "?temp")
  # check that temp dir exists
  assert tmpdir.join("bla").check(dir=1)
  # shutdown
  v.shutdown()
  # now temp is gone
  assert not tmpdir.join("bla").check()
Exemplo n.º 7
0
def path_volume_add_local_test(tmpdir):
    vols_dir = str(tmpdir.join("volumes"))
    v = VolumeManager(vols_base_dir=vols_dir)
    v.setup()
    # without create
    assert not v.add_volume("My")
    # with create
    vol = v.add_volume("My?create")
    assert vol
    # check for vol dir
    vol_path = os.path.join(vols_dir, "My")
    assert os.path.isdir(vol_path)
    assert vol.get_path() == vol_path
    # create multiple
    vols = v.add_volumes(["foo?create", "bar?create"])
    assert vols
    for vol in vols:
        vol_path = os.path.join(vols_dir, vol.get_name())
        assert os.path.isdir(vol_path)
        assert vol.get_path() == vol_path
    # shutdown
    v.shutdown()
Exemplo n.º 8
0
def path_volume_add_local_test(tmpdir):
  vols_dir = str(tmpdir.join("volumes"))
  v = VolumeManager(vols_base_dir=vols_dir)
  v.setup()
  # without create
  assert not v.add_volume("My")
  # with create
  vol = v.add_volume("My?create")
  assert vol
  # check for vol dir
  vol_path = os.path.join(vols_dir, "My")
  assert os.path.isdir(vol_path)
  assert vol.get_path() == vol_path
  # create multiple
  vols = v.add_volumes(["foo?create", "bar?create"])
  assert vols
  for vol in vols:
    vol_path = os.path.join(vols_dir, vol.get_name())
    assert os.path.isdir(vol_path)
    assert vol.get_path() == vol_path
  # shutdown
  v.shutdown()