Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.repo_tests.RepositoryRootNodeTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_has_format_version
def test_accepts_same_format_version
def test_does_not_accept_older_format_version
def test_does_not_accept_newer_version
def test_has_none_version_for_empty_repository
def test_creates_repository_with_format_version
def test_lists_no_clients
def test_has_not_got_root_node_lock
def test_locks_root_node
def test_locking_root_node_twice_fails
def test_commit_releases_lock
def test_unlock_releases_lock
def test_commit_without_lock_fails
def test_unlock_root_without_lock_fails
def test_commit_when_locked_by_other_fails
def test_unlock_root_when_locked_by_other_fails
def test_on_disk_repository_has_no_version_initially
def test_lock_root_adds_version
def test_lock_root_fails_if_format_is_incompatible
def test_list_clients_fails_if_format_is_incompatible
def test_locks_shared
def test_locking_shared_twice_fails
def test_unlocks_shared
def test_unlock_shared_when_locked_by_other_fails
def test_lock_client_fails_if_format_is_incompatible
def test_open_client_fails_if_format_is_incompatible
def test_adding_client_without_root_lock_fails
def test_adds_client
def test_adds_two_clients_across_commits
def test_adds_client_that_persists_after_commit
def test_adding_existing_client_fails
def test_removing_client_without_root_lock_fails
def test_removing_nonexistent_client_fails
def test_removing_client_works
def test_removing_client_persists_past_commit
def test_adding_client_without_commit_does_not_happen
def test_removing_client_without_commit_does_not_happen
def test_removing_client_that_has_data_removes_the_data_as_well

Public Attributes

 tempdir
 fs
 repo
 otherfs
 other

Detailed Description

Definition at line 28 of file repo_tests.py.


Member Function Documentation

Definition at line 30 of file repo_tests.py.

00030 
00031     def setUp(self):
00032         self.tempdir = tempfile.mkdtemp()
00033 
00034         self.fs = obnamlib.LocalFS(self.tempdir)
00035         self.repo = obnamlib.Repository(self.fs, obnamlib.DEFAULT_NODE_SIZE,
00036                                         obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
00037                                         obnamlib.DEFAULT_LRU_SIZE, None,
00038                                         obnamlib.IDPATH_DEPTH,
00039                                         obnamlib.IDPATH_BITS,
00040                                         obnamlib.IDPATH_SKIP,
00041                                         time.time, 0, '')
00042         
00043         self.otherfs = obnamlib.LocalFS(self.tempdir)
00044         self.other = obnamlib.Repository(self.fs, obnamlib.DEFAULT_NODE_SIZE,
00045                                          obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
00046                                          obnamlib.DEFAULT_LRU_SIZE, None,
00047                                         obnamlib.IDPATH_DEPTH,
00048                                         obnamlib.IDPATH_BITS,
00049                                         obnamlib.IDPATH_SKIP,
00050                                         time.time, 0, '')

Definition at line 51 of file repo_tests.py.

00051 
00052     def tearDown(self):
00053         shutil.rmtree(self.tempdir)

Definition at line 57 of file repo_tests.py.

00057 
00058     def test_accepts_same_format_version(self):
00059         self.assert_(self.repo.acceptable_version(self.repo.format_version))

Definition at line 210 of file repo_tests.py.

00210 
00211     def test_adding_client_without_commit_does_not_happen(self):
00212         self.repo.lock_root()
00213         self.repo.add_client('foo')
00214         self.repo.unlock_root()
00215         self.assertEqual(self.repo.list_clients(), [])

Definition at line 155 of file repo_tests.py.

00155 
00156     def test_adding_client_without_root_lock_fails(self):
00157         self.assertRaises(obnamlib.LockFail, self.repo.add_client, 'foo')
        

Definition at line 185 of file repo_tests.py.

00185 
00186     def test_adding_existing_client_fails(self):
00187         self.repo.lock_root()
00188         self.repo.add_client('foo')
00189         self.assertRaises(obnamlib.Error, self.repo.add_client, 'foo')
        

Definition at line 158 of file repo_tests.py.

00158 
00159     def test_adds_client(self):
00160         self.repo.lock_root()
00161         self.repo.add_client('foo')
00162         self.assertEqual(self.repo.list_clients(), ['foo'])
        

Definition at line 172 of file repo_tests.py.

00172 
00173     def test_adds_client_that_persists_after_commit(self):
00174         self.repo.lock_root()
00175         self.repo.add_client('foo')
00176         self.repo.commit_root()
00177         s2 = obnamlib.Repository(self.fs, obnamlib.DEFAULT_NODE_SIZE,
00178                                  obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
00179                                  obnamlib.DEFAULT_LRU_SIZE, None,
00180                                  obnamlib.IDPATH_DEPTH,
00181                                  obnamlib.IDPATH_BITS,
00182                                  obnamlib.IDPATH_SKIP,
00183                                  time.time, 0, '')
00184         self.assertEqual(s2.list_clients(), ['foo'])
        

Definition at line 163 of file repo_tests.py.

00163 
00164     def test_adds_two_clients_across_commits(self):
00165         self.repo.lock_root()
00166         self.repo.add_client('foo')
00167         self.repo.commit_root()
00168         self.repo.lock_root()
00169         self.repo.add_client('bar')
00170         self.repo.commit_root()
00171         self.assertEqual(sorted(self.repo.list_clients()), ['bar', 'foo'])
        

Definition at line 90 of file repo_tests.py.

00090 
00091     def test_commit_releases_lock(self):
00092         self.repo.lock_root()
00093         self.repo.commit_root()
00094         self.assertFalse(self.repo.got_root_lock)
        

Definition at line 106 of file repo_tests.py.

00106 
00107     def test_commit_when_locked_by_other_fails(self):
00108         self.other.lock_root()
00109         self.assertRaises(obnamlib.LockFail, self.repo.commit_root)

Definition at line 100 of file repo_tests.py.

00100 
00101     def test_commit_without_lock_fails(self):
00102         self.assertRaises(obnamlib.LockFail, self.repo.commit_root)
        

Definition at line 71 of file repo_tests.py.

00071 
00072     def test_creates_repository_with_format_version(self):
00073         self.repo.lock_root()
00074         self.assertEqual(self.repo.get_format_version(), 
00075                          self.repo.format_version)

Definition at line 64 of file repo_tests.py.

00064 
00065     def test_does_not_accept_newer_version(self):
00066         newer_version = self.repo.format_version + 1
00067         self.assertFalse(self.repo.acceptable_version(newer_version))
        

Definition at line 60 of file repo_tests.py.

00060 
00061     def test_does_not_accept_older_format_version(self):
00062         older_version = self.repo.format_version - 1
00063         self.assertFalse(self.repo.acceptable_version(older_version))

Definition at line 54 of file repo_tests.py.

00054 
00055     def test_has_format_version(self):
00056         self.assert_(hasattr(self.repo, 'format_version'))

Definition at line 68 of file repo_tests.py.

00068 
00069     def test_has_none_version_for_empty_repository(self):
00070         self.assertEqual(self.repo.get_format_version(), None)
        

Definition at line 79 of file repo_tests.py.

00079 
00080     def test_has_not_got_root_node_lock(self):
00081         self.assertFalse(self.repo.got_root_lock)

Definition at line 126 of file repo_tests.py.

00126 
00127     def test_list_clients_fails_if_format_is_incompatible(self):
00128         self.repo._write_format_version(0)
00129         self.assertRaises(obnamlib.BadFormat, self.repo.list_clients)

Definition at line 76 of file repo_tests.py.

00076 
00077     def test_lists_no_clients(self):
00078         self.assertEqual(self.repo.list_clients(), [])

Definition at line 147 of file repo_tests.py.

00147 
00148     def test_lock_client_fails_if_format_is_incompatible(self):
00149         self.repo._write_format_version(0)
00150         self.assertRaises(obnamlib.BadFormat, self.repo.lock_client, 'foo')

Definition at line 117 of file repo_tests.py.

00117 
00118     def test_lock_root_adds_version(self):
00119         self.repo.lock_root()
00120         self.assertEqual(self.repo.get_format_version(),
00121                          self.repo.format_version)

Definition at line 122 of file repo_tests.py.

00122 
00123     def test_lock_root_fails_if_format_is_incompatible(self):
00124         self.repo._write_format_version(0)
00125         self.assertRaises(obnamlib.BadFormat, self.repo.lock_root)

Definition at line 86 of file repo_tests.py.

00086 
00087     def test_locking_root_node_twice_fails(self):
00088         self.repo.lock_root()
00089         self.assertRaises(obnamlib.Error, self.repo.lock_root)
        

Definition at line 134 of file repo_tests.py.

00134 
00135     def test_locking_shared_twice_fails(self):
00136         self.repo.lock_shared()
00137         self.assertRaises(obnamlib.Error, self.repo.lock_shared)

Definition at line 82 of file repo_tests.py.

00082 
00083     def test_locks_root_node(self):
00084         self.repo.lock_root()
00085         self.assert_(self.repo.got_root_lock)
        

Definition at line 130 of file repo_tests.py.

00130 
00131     def test_locks_shared(self):
00132         self.repo.lock_shared()
00133         self.assertTrue(self.repo.got_shared_lock)
        

Definition at line 114 of file repo_tests.py.

00114 
00115     def test_on_disk_repository_has_no_version_initially(self):
00116         self.assertEqual(self.repo.get_format_version(), None)

Definition at line 151 of file repo_tests.py.

00151 
00152     def test_open_client_fails_if_format_is_incompatible(self):
00153         self.repo._write_format_version(0)
00154         self.assertRaises(obnamlib.BadFormat, self.repo.open_client, 'foo')
        

Definition at line 203 of file repo_tests.py.

00203 
00204     def test_removing_client_persists_past_commit(self):
00205         self.repo.lock_root()
00206         self.repo.add_client('foo')
00207         self.repo.remove_client('foo')
00208         self.repo.commit_root()
00209         self.assertEqual(self.repo.list_clients(), [])

Definition at line 225 of file repo_tests.py.

00225 
00226     def test_removing_client_that_has_data_removes_the_data_as_well(self):
00227         self.repo.lock_root()
00228         self.repo.add_client('foo')
00229         self.repo.commit_root()
00230 
00231         self.repo.lock_client('foo')
00232         self.repo.lock_shared()
00233         self.repo.start_generation()
00234         self.repo.create('/', obnamlib.Metadata())
00235         self.repo.commit_client()
00236         self.repo.commit_shared()
00237 
00238         self.repo.lock_root()
00239         self.repo.remove_client('foo')
00240         self.repo.commit_root()
00241 
00242         self.assertEqual(self.repo.list_clients(), [])
00243         self.assertFalse(self.fs.exists('foo'))
00244 

Definition at line 216 of file repo_tests.py.

00216 
00217     def test_removing_client_without_commit_does_not_happen(self):
00218         self.repo.lock_root()
00219         self.repo.add_client('foo')
00220         self.repo.commit_root()
00221         self.repo.lock_root()
00222         self.repo.remove_client('foo')
00223         self.repo.unlock_root()
00224         self.assertEqual(self.repo.list_clients(), ['foo'])

Definition at line 190 of file repo_tests.py.

00190 
00191     def test_removing_client_without_root_lock_fails(self):
00192         self.assertRaises(obnamlib.LockFail, self.repo.remove_client, 'foo')
        

Definition at line 197 of file repo_tests.py.

00197 
00198     def test_removing_client_works(self):
00199         self.repo.lock_root()
00200         self.repo.add_client('foo')
00201         self.repo.remove_client('foo')
00202         self.assertEqual(self.repo.list_clients(), [])
        

Definition at line 193 of file repo_tests.py.

00193 
00194     def test_removing_nonexistent_client_fails(self):
00195         self.repo.lock_root()
00196         self.assertRaises(obnamlib.Error, self.repo.remove_client, 'foo')
        

Definition at line 95 of file repo_tests.py.

00095 
00096     def test_unlock_releases_lock(self):
00097         self.repo.lock_root()
00098         self.repo.unlock_root()
00099         self.assertFalse(self.repo.got_root_lock)
        

Definition at line 110 of file repo_tests.py.

00110 
00111     def test_unlock_root_when_locked_by_other_fails(self):
00112         self.other.lock_root()
00113         self.assertRaises(obnamlib.LockFail, self.repo.unlock_root)

Definition at line 103 of file repo_tests.py.

00103 
00104     def test_unlock_root_without_lock_fails(self):
00105         self.assertRaises(obnamlib.LockFail, self.repo.unlock_root)

Definition at line 143 of file repo_tests.py.

00143 
00144     def test_unlock_shared_when_locked_by_other_fails(self):
00145         self.other.lock_shared()
00146         self.assertRaises(obnamlib.LockFail, self.repo.unlock_shared)

Definition at line 138 of file repo_tests.py.

00138 
00139     def test_unlocks_shared(self):
00140         self.repo.lock_shared()
00141         self.repo.unlock_shared()
00142         self.assertFalse(self.repo.got_shared_lock)


Member Data Documentation

Definition at line 33 of file repo_tests.py.

Definition at line 43 of file repo_tests.py.

Definition at line 42 of file repo_tests.py.

Definition at line 34 of file repo_tests.py.

Definition at line 31 of file repo_tests.py.


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