Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_checksum_returns_checksum
def test_put_chunk_returns_id
def test_get_chunk_retrieves_what_put_chunk_puts
def test_chunk_does_not_exist
def test_chunk_exists_after_it_is_put
def test_removes_chunk
def test_silently_ignores_failure_when_removing_nonexistent_chunk
def test_find_chunks_finds_what_put_chunk_puts
def test_find_chunks_finds_nothing_if_nothing_is_put
def test_handles_checksum_collision
def test_returns_no_chunks_initially
def test_returns_chunks_after_they_exist

Public Attributes

 tempdir
 fs
 repo

Detailed Description

Definition at line 579 of file repo_tests.py.


Member Function Documentation

Definition at line 581 of file repo_tests.py.

00581 
00582     def setUp(self):
00583         self.tempdir = tempfile.mkdtemp()
00584 
00585         self.fs = obnamlib.LocalFS(self.tempdir)
00586         self.repo = obnamlib.Repository(self.fs, obnamlib.DEFAULT_NODE_SIZE,
00587                                         obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
00588                                         obnamlib.DEFAULT_LRU_SIZE, None,
00589                                         obnamlib.IDPATH_DEPTH,
00590                                         obnamlib.IDPATH_BITS,
00591                                         obnamlib.IDPATH_SKIP,
00592                                         time.time, 0, '')
00593         self.repo.lock_root()
00594         self.repo.add_client('client_name')
00595         self.repo.commit_root()
00596         self.repo.lock_client('client_name')
00597         self.repo.start_generation()

Definition at line 598 of file repo_tests.py.

00598 
00599     def tearDown(self):
00600         shutil.rmtree(self.tempdir)

Definition at line 601 of file repo_tests.py.

00601 
00602     def test_checksum_returns_checksum(self):
00603         self.assertNotEqual(self.repo.checksum('data'), None)

Definition at line 613 of file repo_tests.py.

00613 
00614     def test_chunk_does_not_exist(self):
00615         self.assertFalse(self.repo.chunk_exists(1234))
        

Definition at line 616 of file repo_tests.py.

00616 
00617     def test_chunk_exists_after_it_is_put(self):
00618         self.repo.lock_shared()
00619         chunkid = self.repo.put_chunk_only('chunk')
00620         self.assert_(self.repo.chunk_exists(chunkid))

Definition at line 638 of file repo_tests.py.

00638 
00639     def test_find_chunks_finds_nothing_if_nothing_is_put(self):
00640         self.assertEqual(self.repo.find_chunks('checksum'), [])
        

Definition at line 631 of file repo_tests.py.

00631 
00632     def test_find_chunks_finds_what_put_chunk_puts(self):
00633         self.repo.lock_shared()
00634         checksum = self.repo.checksum('data')
00635         chunkid = self.repo.put_chunk_only('data')
00636         self.repo.put_chunk_in_shared_trees(chunkid, checksum)
00637         self.assertEqual(self.repo.find_chunks(checksum), [chunkid])
        

Definition at line 608 of file repo_tests.py.

00608 
00609     def test_get_chunk_retrieves_what_put_chunk_puts(self):
00610         self.repo.lock_shared()
00611         chunkid = self.repo.put_chunk_only('data')
00612         self.assertEqual(self.repo.get_chunk(chunkid), 'data')
        

Definition at line 641 of file repo_tests.py.

00641 
00642     def test_handles_checksum_collision(self):
00643         self.repo.lock_shared()
00644         checksum = self.repo.checksum('data')
00645         chunkid1 = self.repo.put_chunk_only('data')
00646         chunkid2 = self.repo.put_chunk_only('data')
00647         self.repo.put_chunk_in_shared_trees(chunkid1, checksum)
00648         self.repo.put_chunk_in_shared_trees(chunkid2, checksum)
00649         self.assertEqual(set(self.repo.find_chunks(checksum)),
00650                          set([chunkid1, chunkid2]))

Definition at line 604 of file repo_tests.py.

00604 
00605     def test_put_chunk_returns_id(self):
00606         self.repo.lock_shared()
00607         self.assertNotEqual(self.repo.put_chunk_only('data'), None)
        

Definition at line 621 of file repo_tests.py.

00621 
00622     def test_removes_chunk(self):
00623         self.repo.lock_shared()
00624         chunkid = self.repo.put_chunk_only('chunk')
00625         self.repo.remove_chunk(chunkid)
00626         self.assertFalse(self.repo.chunk_exists(chunkid))

Definition at line 654 of file repo_tests.py.

00654 
00655     def test_returns_chunks_after_they_exist(self):
00656         self.repo.lock_shared()
00657         checksum = self.repo.checksum('data')
00658         chunkids = []
00659         for i in range(2):
00660             chunkids.append(self.repo.put_chunk_only('data'))
00661         self.assertEqual(sorted(self.repo.list_chunks()), sorted(chunkids))
00662 

Definition at line 651 of file repo_tests.py.

00651 
00652     def test_returns_no_chunks_initially(self):
00653         self.assertEqual(self.repo.list_chunks(), [])
        

Definition at line 627 of file repo_tests.py.

00627 
00628     def test_silently_ignores_failure_when_removing_nonexistent_chunk(self):
00629         self.repo.lock_shared()
00630         self.assertEqual(self.repo.remove_chunk(0), None)
        

Member Data Documentation

Definition at line 584 of file repo_tests.py.

Definition at line 585 of file repo_tests.py.

Definition at line 582 of file repo_tests.py.


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