6
6
from landscape.lib.fs import create_file
7
from landscape.package.facade import AptFacade
10
class AptFacadeHelper(object):
11
"""Helper that sets up an AptFacade with a tempdir as its root."""
13
def set_up(self, test_case):
14
test_case.apt_root = test_case.makeDir()
15
# Create all the required directories, so that apt doesn't
16
# auto-create them, which causing the paths to be printed to stdout.
17
test_case.dpkg_dir = self._create_sub_dir(test_case, "var/lib/dpkg")
18
self._create_sub_dir(test_case, "etc/apt")
19
self._create_sub_dir(test_case, "var/cache/apt/archives/partial")
20
self._create_sub_dir(test_case, "var/lib/apt/lists/partial")
21
test_case.dpkg_status = os.path.join(test_case.dpkg_dir, "status")
22
with open(test_case.dpkg_status, "w") as status_file:
24
test_case.facade = AptFacade(root=test_case.apt_root)
26
def _create_sub_dir(self, test_case, sub_dir):
27
"""Create a dir instead the Apt root dir."""
28
full_path = os.path.join(test_case.apt_root, sub_dir)
29
os.makedirs(full_path)
9
33
class SmartHelper(object):