Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.metadata_tests.SetMetadataTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def fake_lchown
def test_sets_atime
def test_sets_mode
def test_sets_mtime
def test_does_not_set_uid_when_not_running_as_root
def test_does_not_set_gid_when_not_running_as_root
def test_sets_uid_when_running_as_root
def test_sets_gid_when_running_as_root
def test_sets_symlink_target
def test_sets_symlink_mtime_perms

Public Attributes

 metadata
 filename
 fs
 uid_set
 gid_set
 st

Detailed Description

Definition at line 164 of file metadata_tests.py.


Member Function Documentation

def obnamlib.metadata_tests.SetMetadataTests.fake_lchown (   self,
  filename,
  uid,
  gid 
)

Definition at line 194 of file metadata_tests.py.

00194 
00195     def fake_lchown(self, filename, uid, gid):
00196         self.uid_set = uid
00197         self.gid_set = gid
        

Definition at line 166 of file metadata_tests.py.

00166 
00167     def setUp(self):
00168         self.metadata = obnamlib.Metadata()
00169         self.metadata.st_atime_sec = 12765
00170         self.metadata.st_atime_nsec = 0
00171         self.metadata.st_mode = 42 | stat.S_IFREG
00172         self.metadata.st_mtime_sec = 10**9
00173         self.metadata.st_mtime_nsec = 0
00174         self.metadata.st_uid = 1234
00175         self.metadata.st_gid = 5678
00176         
00177         fd, self.filename = tempfile.mkstemp()
00178         os.close(fd)
00179         
00180         self.fs = obnamlib.LocalFS('/')
00181         self.fs.connect()
00182 
00183         self.uid_set = None
00184         self.gid_set = None
00185         self.fs.lchown = self.fake_lchown
00186 
00187         obnamlib.set_metadata(self.fs, self.filename, self.metadata)
00188         
00189         self.st = os.stat(self.filename)
        

Definition at line 190 of file metadata_tests.py.

00190 
00191     def tearDown(self):
00192         self.fs.close()
00193         os.remove(self.filename)

Definition at line 210 of file metadata_tests.py.

00210 
00211     def test_does_not_set_gid_when_not_running_as_root(self):
00212         self.assertEqual(self.st.st_gid, os.getgid())

Definition at line 207 of file metadata_tests.py.

00207 
00208     def test_does_not_set_uid_when_not_running_as_root(self):
00209         self.assertEqual(self.st.st_uid, os.getuid())

Definition at line 198 of file metadata_tests.py.

00198 
00199     def test_sets_atime(self):
00200         self.assertEqual(self.st.st_atime, self.metadata.st_atime_sec)

Definition at line 218 of file metadata_tests.py.

00218 
00219     def test_sets_gid_when_running_as_root(self):
00220         obnamlib.set_metadata(self.fs, self.filename, self.metadata,
00221                               getuid=lambda: 0)
00222         self.assertEqual(self.gid_set, self.metadata.st_gid)

Definition at line 201 of file metadata_tests.py.

00201 
00202     def test_sets_mode(self):
00203         self.assertEqual(self.st.st_mode, self.metadata.st_mode)

Definition at line 204 of file metadata_tests.py.

00204 
00205     def test_sets_mtime(self):
00206         self.assertEqual(self.st.st_mtime, self.metadata.st_mtime_sec)

Definition at line 230 of file metadata_tests.py.

00230 
00231     def test_sets_symlink_mtime_perms(self):
00232         self.fs.remove(self.filename)
00233         self.metadata.st_mode = 0777 | stat.S_IFLNK;
00234         self.metadata.target = 'target'
00235         obnamlib.set_metadata(self.fs, self.filename, self.metadata)
00236         st = os.lstat(self.filename)
00237         self.assertEqual(st.st_mode, self.metadata.st_mode)
00238         self.assertEqual(st.st_mtime, self.metadata.st_mtime_sec)
00239 

Definition at line 223 of file metadata_tests.py.

00223 
00224     def test_sets_symlink_target(self):
00225         self.fs.remove(self.filename)
00226         self.metadata.st_mode = 0777 | stat.S_IFLNK;
00227         self.metadata.target = 'target'
00228         obnamlib.set_metadata(self.fs, self.filename, self.metadata)
00229         self.assertEqual(self.fs.readlink(self.filename), 'target')

Definition at line 213 of file metadata_tests.py.

00213 
00214     def test_sets_uid_when_running_as_root(self):
00215         obnamlib.set_metadata(self.fs, self.filename, self.metadata,
00216                               getuid=lambda: 0)
00217         self.assertEqual(self.uid_set, self.metadata.st_uid)


Member Data Documentation

Definition at line 176 of file metadata_tests.py.

Definition at line 179 of file metadata_tests.py.

Definition at line 183 of file metadata_tests.py.

Definition at line 167 of file metadata_tests.py.

Definition at line 188 of file metadata_tests.py.

Definition at line 182 of file metadata_tests.py.


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