| 1 |
import os |
|---|
| 2 |
import shutil |
|---|
| 3 |
import tempfile |
|---|
| 4 |
|
|---|
| 5 |
import _path_cheesecake |
|---|
| 6 |
from cheesecake.cheesecake_index import Cheesecake |
|---|
| 7 |
|
|---|
| 8 |
datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data")) |
|---|
| 9 |
|
|---|
| 10 |
class TestInitCleanup(object): |
|---|
| 11 |
def tearDown(self): |
|---|
| 12 |
if hasattr(self, 'cheesecake'): |
|---|
| 13 |
if os.path.isdir(self.cheesecake.sandbox): |
|---|
| 14 |
shutil.rmtree(self.cheesecake.sandbox) |
|---|
| 15 |
if hasattr(self, 'logfile'): |
|---|
| 16 |
if os.path.isfile(self.logfile): |
|---|
| 17 |
os.unlink(self.logfile) |
|---|
| 18 |
|
|---|
| 19 |
def test_init(self): |
|---|
| 20 |
self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tar.gz")) |
|---|
| 21 |
assert os.path.isdir(self.cheesecake.sandbox_pkg_dir) |
|---|
| 22 |
assert os.path.isfile(self.cheesecake.sandbox_pkg_file) |
|---|
| 23 |
self.logfile = self.cheesecake.logfile |
|---|
| 24 |
assert os.path.isfile(self.logfile) |
|---|
| 25 |
|
|---|
| 26 |
def test_init_custom_logfile(self): |
|---|
| 27 |
self.logfile = tempfile.mktemp() |
|---|
| 28 |
self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tar.gz"), |
|---|
| 29 |
logfile=self.logfile) |
|---|
| 30 |
assert os.path.isdir(self.cheesecake.sandbox_pkg_dir) |
|---|
| 31 |
assert os.path.isfile(self.cheesecake.sandbox_pkg_file) |
|---|
| 32 |
assert os.path.isfile(self.logfile) |
|---|
| 33 |
|
|---|
| 34 |
def test_cleanup_after_install(self): |
|---|
| 35 |
self.cheesecake = Cheesecake(path=os.path.join(datadir, "package1.tar.gz")) |
|---|
| 36 |
self.cheesecake.cleanup() |
|---|
| 37 |
assert not os.path.exists(self.cheesecake.sandbox_pkg_dir) |
|---|
| 38 |
assert not os.path.exists(self.cheesecake.sandbox_pkg_file) |
|---|
| 39 |
assert not os.path.exists(self.cheesecake.sandbox_install_dir) |
|---|
| 40 |
assert not os.path.exists(self.cheesecake.sandbox) |
|---|
| 41 |
self.logfile = self.cheesecake.logfile |
|---|
| 42 |
assert not os.path.isfile(self.logfile) |
|---|