def test_group_inexistent(tmpdir, monkeypatch): build_directory(tmpdir) monkeypatch.setattr('pwd.getpwnam', helpers.getpwnam) monkeypatch.setattr('grp.getgrnam', helpers.getgrnam) monkeypatch.setattr('os.stat', directory_stat) find = Find(path=tmpdir.strpath, group='wow') with pytest.raises(ActionError): find.process()
def test_flags(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, flags=['hidden']) assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('filea1.yaml').strpath, tmpdir.join('test/fileb2.json').strpath ] })
def test_mode(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, mode='0600') assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('filea2.json').strpath, tmpdir.join('test/fileb2.json').strpath ] })
def test_types_directory(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, types=['directory']) assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('test').strpath, tmpdir.join('test/wow').strpath ] })
def test_types_symlink(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, types=['symlink']) assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('test/symlinkb1.txt').strpath, tmpdir.join('test/symlinkb2.json').strpath, tmpdir.join('test/symlinkb3.txt').strpath ] })
def test_group(tmpdir, monkeypatch): build_directory(tmpdir) monkeypatch.setattr('pwd.getpwnam', helpers.getpwnam) monkeypatch.setattr('grp.getgrnam', helpers.getgrnam) monkeypatch.setattr('os.stat', directory_stat) find = Find(path=tmpdir.strpath, group='wheel') assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('test/fileb1.txt').strpath, tmpdir.join('test/wow/filec2.txt').strpath ] })
def test_owner(tmpdir, monkeypatch): build_directory(tmpdir) monkeypatch.setattr('pwd.getpwnam', helpers.getpwnam) monkeypatch.setattr('grp.getgrnam', helpers.getgrnam) monkeypatch.setattr('os.stat', directory_stat) find = Find(path=tmpdir.strpath, owner='happy') assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('filea3.txt').strpath, tmpdir.join('test/fileb3.txt').strpath ] })
def test_types_file_without_aliases(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, types=['file'], aliases=False) assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('filea1.yaml').strpath, tmpdir.join('filea2.json').strpath, tmpdir.join('filea3.txt').strpath, tmpdir.join('test/fileb1.txt').strpath, tmpdir.join('test/fileb2.json').strpath, tmpdir.join('test/fileb3.txt').strpath, tmpdir.join('test/wow/filec1.zip').strpath, tmpdir.join('test/wow/filec2.txt').strpath, tmpdir.join('test/wow/filec3.yaml').strpath ] })
def test_min_depth(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, min_depth=2) assert find.process() == ActionResponse(changed=False, data={ 'paths': [ tmpdir.join('test/fileb1.txt').strpath, tmpdir.join('test/fileb2.json').strpath, tmpdir.join('test/fileb3.txt').strpath, tmpdir.join('test/symlinkb1.txt').strpath, tmpdir.join('test/symlinkb2.json').strpath, tmpdir.join('test/symlinkb3.txt').strpath, tmpdir.join('test/wow').strpath, tmpdir.join('test/wow/filec1.zip').strpath, tmpdir.join('test/wow/filec2.txt').strpath, tmpdir.join('test/wow/filec3.yaml').strpath ] })
def test_path_inexistent(tmpdir): p = tmpdir.join('test') find = Find(path=p.strpath) with pytest.raises(ActionError): find.process()
def test_flags_invalid(tmpdir): build_directory(tmpdir) find = Find(path=tmpdir.strpath, flags=['hmmm']) with pytest.raises(ActionError): find.process()