File: test_cleanup_folder.py

package info (click to toggle)
ansible-runner 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,232 kB
  • sloc: python: 9,896; makefile: 19
file content (23 lines) | stat: -rw-r--r-- 659 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from ansible_runner.utils import cleanup_folder


def test_cleanup_folder(tmp_path):
    folder_path = tmp_path / 'a_folder'
    folder_path.mkdir()
    assert folder_path.exists()  # sanity
    cleanup_folder(str(folder_path))
    assert not folder_path.exists()


def test_cleanup_folder_already_deleted(tmp_path):
    missing_dir = tmp_path / 'missing'
    assert not missing_dir.exists()  # sanity
    cleanup_folder(str(missing_dir))
    assert not missing_dir.exists()


def test_cleanup_folder_file_no_op(tmp_path):
    file_path = tmp_path / 'a_file'
    file_path.write_text('foobar')
    cleanup_folder(str(file_path))
    assert file_path.exists()