~ubuntu-branches/ubuntu/raring/apt-clone/raring

« back to all changes in this revision

Viewing changes to tests/test_in_chroot.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-02-16 20:17:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110216201752-gb1fn94tkd7acp6q
Tags: 0.1
initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import apt
 
4
import logging
 
5
import os
 
6
import subprocess
 
7
import sys
 
8
import unittest
 
9
 
 
10
 
 
11
sys.path.insert(0, "..")
 
12
from apt_clone import AptClone
 
13
 
 
14
class MockAptCache(apt.Cache):
 
15
    def commit(self, fetchp, installp):
 
16
        pass
 
17
    def update(self, fetchp):
 
18
        pass
 
19
 
 
20
class TestClone(unittest.TestCase):
 
21
 
 
22
    def test_real(self):
 
23
        if os.getuid() != 0:
 
24
            print "Skipping because uid != 0"
 
25
            return
 
26
        target = "./tests/test-chroot"
 
27
        if not os.path.exists(target):
 
28
            os.mkdir(target)
 
29
            subprocess.call(["debootstrap", "--arch=i386",
 
30
                             "maverick", target])
 
31
        # force i386
 
32
        open(os.path.join(target, "etc/apt/apt.conf"), "w").write(
 
33
            'APT::Architecture "i386";')
 
34
        # restore
 
35
        clone = AptClone()
 
36
        clone.restore_state(
 
37
            "./tests/data/apt-state_chroot_with_vim.tar.gz", target, "maverick")
 
38
 
 
39
if __name__ == "__main__":
 
40
    logging.basicConfig(level=logging.DEBUG)
 
41
    unittest.main()