Example #1
0
def test_mode_ensures_mode_for_directories(root):
    path = "path"
    os.makedirs("work/mycomponent/path")
    mode = Mode(path, mode=0o000)
    root.component += mode
    root.component.deploy()
    assert S_IMODE(os.stat(mode.path).st_mode) == 0o000

    mode.mode = 0o777
    root.component.deploy()
    assert S_IMODE(os.stat(mode.path).st_mode) == 0o777
    assert mode.changed

    root.component.deploy()
    assert not mode.changed
Example #2
0
def test_mode_ensures_mode_for_files(root):
    path = "path"
    open("work/mycomponent/" + path, "w").close()
    mode = Mode(path, mode=0o000)
    root.component += mode
    root.component.deploy()
    assert S_IMODE(os.stat(mode.path).st_mode) == 0o000

    mode.mode = 0o777
    root.component.deploy()
    assert S_IMODE(os.stat(mode.path).st_mode) == 0o777
    assert mode.changed

    root.component.deploy()
    assert not mode.changed
Example #3
0
def test_mode_ensures_mode_for_symlinks(root):
    # This test is only relevant on platforms that support managing the mode of
    # symlinks.
    link_to = "link_to"
    open(link_to, "w").close()
    os.symlink(link_to, "work/mycomponent/path")
    mode = Mode("path", mode=0o000)
    root.component += mode
    root.component.deploy()
    assert S_IMODE(os.lstat("work/mycomponent/path").st_mode) == 0o000

    mode.mode = 0o777
    root.component.deploy()
    assert S_IMODE(os.lstat("work/mycomponent/path").st_mode) == 0o777
    assert mode.changed

    root.component.deploy()
    assert not mode.changed