Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
unit-nsinstall.TestNsinstall Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def touch
def mkdirs
def test_nsinstall_D
def test_nsinstall_basic
def test_nsinstall_basic_recursive
def test_nsinstall_multiple
def test_nsinstall_dir_exists
def test_nsinstall_t
def test_nsinstall_m
def test_nsinstall_d

Public Attributes

 tmpdir

Detailed Description

Unit tests for nsinstall.py

Definition at line 10 of file unit-nsinstall.py.


Member Function Documentation

def unit-nsinstall.TestNsinstall.mkdirs (   self,
  dir 
)

Definition at line 28 of file unit-nsinstall.py.

00028 
00029     def mkdirs(self, dir):
00030         d = os.path.join(self.tmpdir, dir)
00031         os.makedirs(d)
00032         return d

Here is the caller graph for this function:

def unit-nsinstall.TestNsinstall.setUp (   self)

Definition at line 14 of file unit-nsinstall.py.

00014 
00015     def setUp(self):
00016         self.tmpdir = mkdtemp()

def unit-nsinstall.TestNsinstall.tearDown (   self)

Definition at line 17 of file unit-nsinstall.py.

00017 
00018     def tearDown(self):
00019         rmtree(self.tmpdir)

def unit-nsinstall.TestNsinstall.test_nsinstall_basic (   self)

Definition at line 39 of file unit-nsinstall.py.

00039 
00040     def test_nsinstall_basic(self):
00041         "Test nsinstall <file> <dir>"
00042         testfile = self.touch("testfile")
00043         testdir = self.mkdirs("testdir")
00044         self.assertEqual(nsinstall([testfile, testdir]), 0)
00045         self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_basic_recursive (   self)

Definition at line 46 of file unit-nsinstall.py.

00046 
00047     def test_nsinstall_basic_recursive(self):
00048         "Test nsinstall <dir> <dest dir>"
00049         sourcedir = self.mkdirs("sourcedir")
00050         self.touch("testfile", sourcedir)
00051         destdir = self.mkdirs("destdir")
00052         self.assertEqual(nsinstall([sourcedir, destdir]), 0)
00053         testdir = os.path.join(destdir, "sourcedir")
00054         self.assert_(os.path.isdir(testdir))
00055         self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_D (   self)

Definition at line 33 of file unit-nsinstall.py.

00033 
00034     def test_nsinstall_D(self):
00035         "Test nsinstall -D <dir>"
00036         testdir = os.path.join(self.tmpdir, "test")
00037         self.assertEqual(nsinstall(["-D", testdir]), 0)
00038         self.assert_(os.path.isdir(testdir))

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_d (   self)

Definition at line 101 of file unit-nsinstall.py.

00101 
00102     def test_nsinstall_d(self):
00103         "Test that nsinstall -d works (create directories in target)"
00104         # -d makes no sense to me, but ok!
00105         testfile = self.touch("testfile")
00106         testdir = self.mkdirs("testdir")
00107         destdir = os.path.join(testdir, "subdir")
00108         self.assertEqual(nsinstall(["-d", testfile, destdir]), 0)
00109         self.assert_(os.path.isdir(os.path.join(destdir, "testfile")))

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_dir_exists (   self)

Definition at line 67 of file unit-nsinstall.py.

00067 
00068     def test_nsinstall_dir_exists(self):
00069         "Test nsinstall <dir> <dest dir>, where <dest dir>/<dir> already exists"
00070         srcdir = self.mkdirs("test")
00071         destdir = self.mkdirs("testdir/test")
00072         self.assertEqual(nsinstall([srcdir, os.path.dirname(destdir)]), 0)
00073         self.assert_(os.path.isdir(destdir))

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_m (   self)

Definition at line 89 of file unit-nsinstall.py.

00089 
00090         def test_nsinstall_m(self):
00091             "Test that nsinstall -m works (set mode)"
00092             testfile = self.touch("testfile")
00093             mode = 0600
00094             os.chmod(testfile, mode)
00095             testdir = self.mkdirs("testdir")
00096             self.assertEqual(nsinstall(["-m", "%04o" % mode, testfile, testdir]), 0)
00097             destfile = os.path.join(testdir, "testfile")
00098             self.assert_(os.path.isfile(destfile))
00099             self.assertEqual(os.stat(testfile).st_mode,
00100                              os.stat(destfile).st_mode)

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_multiple (   self)

Definition at line 56 of file unit-nsinstall.py.

00056 
00057     def test_nsinstall_multiple(self):
00058         "Test nsinstall <three files> <dest dir>"
00059         testfiles = [self.touch("testfile1"),
00060                      self.touch("testfile2"),
00061                      self.touch("testfile3")]
00062         testdir = self.mkdirs("testdir")
00063         self.assertEqual(nsinstall(testfiles + [testdir]), 0)
00064         for f in testfiles:
00065             self.assert_(os.path.isfile(os.path.join(testdir,
00066                                                      os.path.basename(f))))

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.test_nsinstall_t (   self)

Definition at line 74 of file unit-nsinstall.py.

00074 
00075     def test_nsinstall_t(self):
00076         "Test that nsinstall -t works (preserve timestamp)"
00077         testfile = self.touch("testfile")
00078         testdir = self.mkdirs("testdir")
00079         # set mtime to now - 30 seconds
00080         t = int(time.time()) - 30
00081         os.utime(testfile, (t, t))
00082         self.assertEqual(nsinstall(["-t", testfile, testdir]), 0)
00083         destfile = os.path.join(testdir, "testfile")
00084         self.assert_(os.path.isfile(destfile))
00085         self.assertEqual(os.stat(testfile).st_mtime,
00086                          os.stat(destfile).st_mtime)

Here is the call graph for this function:

def unit-nsinstall.TestNsinstall.touch (   self,
  file,
  dir = None 
)

Definition at line 21 of file unit-nsinstall.py.

00021 
00022     def touch(self, file, dir=None):
00023         if dir is None:
00024             dir = self.tmpdir
00025         f = os.path.join(dir, file)
00026         open(f, 'w').close()
00027         return f

Here is the caller graph for this function:


Member Data Documentation

unit-nsinstall.TestNsinstall.tmpdir

Definition at line 15 of file unit-nsinstall.py.


The documentation for this class was generated from the following file: