Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.checksumtree_tests.ChecksumTreeTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_is_empty_initially
def test_finds_checksums
def test_finds_only_the_right_checksums
def test_removes_checksum
def test_adds_same_id_only_once
def test_unknown_chunk_is_not_used
def test_known_chunk_is_used

Public Attributes

 tempdir
 hooks
 checksum
 tree

Detailed Description

Definition at line 25 of file checksumtree_tests.py.


Member Function Documentation

Definition at line 27 of file checksumtree_tests.py.

00027 
00028     def setUp(self):
00029         self.tempdir = tempfile.mkdtemp()
00030         fs = obnamlib.LocalFS(self.tempdir)
00031         self.hooks = obnamlib.HookManager()
00032         self.hooks.new('repository-toplevel-init')
00033         self.checksum = hashlib.md5('foo').digest()
00034         self.tree = obnamlib.ChecksumTree(fs, 'x', len(self.checksum), 
00035                                           obnamlib.DEFAULT_NODE_SIZE,
00036                                           obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
00037                                           obnamlib.DEFAULT_LRU_SIZE, self)

Definition at line 38 of file checksumtree_tests.py.

00038 
00039     def tearDown(self):
00040         self.tree.commit()
00041         shutil.rmtree(self.tempdir)

Definition at line 62 of file checksumtree_tests.py.

00062 
00063     def test_adds_same_id_only_once(self):
00064         self.tree.add(self.checksum, 1, 2)
00065         self.tree.add(self.checksum, 1, 2)
00066         self.assertEqual(self.tree.find(self.checksum), [1])

Definition at line 45 of file checksumtree_tests.py.

00045 
00046     def test_finds_checksums(self):
00047         self.tree.add(self.checksum, 1, 3)
00048         self.tree.add(self.checksum, 2, 4)
00049         self.assertEqual(sorted(self.tree.find(self.checksum)), [1, 2])

Definition at line 50 of file checksumtree_tests.py.

00050 
00051     def test_finds_only_the_right_checksums(self):
00052         self.tree.add(self.checksum, 1, 2)
00053         self.tree.add(self.checksum, 3, 4)
00054         self.tree.add(hashlib.md5('bar').digest(), 5, 6)
00055         self.assertEqual(sorted(self.tree.find(self.checksum)), [1, 3])

Definition at line 42 of file checksumtree_tests.py.

00042 
00043     def test_is_empty_initially(self):
00044         self.assertEqual(self.tree.find(self.checksum), [])

Definition at line 70 of file checksumtree_tests.py.

00070 
00071     def test_known_chunk_is_used(self):
00072         self.tree.add(self.checksum, 0, 1)
00073         self.assertTrue(self.tree.chunk_is_used(self.checksum, 0))
00074 

Definition at line 56 of file checksumtree_tests.py.

00056 
00057     def test_removes_checksum(self):
00058         self.tree.add(self.checksum, 1, 3)
00059         self.tree.add(self.checksum, 2, 4)
00060         self.tree.remove(self.checksum, 2, 4)
00061         self.assertEqual(self.tree.find(self.checksum), [1])

Definition at line 67 of file checksumtree_tests.py.

00067 
00068     def test_unknown_chunk_is_not_used(self):
00069         self.assertFalse(self.tree.chunk_is_used(self.checksum, 0))


Member Data Documentation

Definition at line 32 of file checksumtree_tests.py.

Definition at line 30 of file checksumtree_tests.py.

Definition at line 28 of file checksumtree_tests.py.

Definition at line 33 of file checksumtree_tests.py.


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