Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.clientlist_tests.ClientListTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_key_bytes_is_correct_length
def test_unkey_unpacks_key_correctly
def test_reports_none_as_id_for_nonexistent_client
def test_lists_no_clients_when_tree_does_not_exist
def test_added_client_has_integer_id
def test_added_client_is_listed
def test_removed_client_has_none_id
def test_removed_client_has_no_keys
def test_twice_added_client_exists_only_once
def test_adding_handles_hash_collision
def test_client_has_no_public_key_initially
def test_sets_client_keyid
def test_remove_client_keyid

Public Attributes

 tempdir
 hooks
 list

Detailed Description

Definition at line 24 of file clientlist_tests.py.


Member Function Documentation

Definition at line 26 of file clientlist_tests.py.

00026 
00027     def setUp(self):
00028         self.tempdir = tempfile.mkdtemp()
00029         fs = obnamlib.LocalFS(self.tempdir)
00030         self.hooks = obnamlib.HookManager()
00031         self.hooks.new('repository-toplevel-init')
00032         self.list = obnamlib.ClientList(fs, 
00033                                         obnamlib.DEFAULT_NODE_SIZE,
00034                                         obnamlib.DEFAULT_UPLOAD_QUEUE_SIZE,
00035                                         obnamlib.DEFAULT_LRU_SIZE, self)

Definition at line 36 of file clientlist_tests.py.

00036 
00037     def tearDown(self):
00038         shutil.rmtree(self.tempdir)

Definition at line 55 of file clientlist_tests.py.

00055 
00056     def test_added_client_has_integer_id(self):
00057         self.list.add_client('foo')
00058         self.assert_(type(self.list.get_client_id('foo')) in [int, long])

Definition at line 59 of file clientlist_tests.py.

00059 
00060     def test_added_client_is_listed(self):
00061         self.list.add_client('foo')
00062         self.list.set_client_keyid('foo', 'cafebeef')
00063         self.assertEqual(self.list.list_clients(), ['foo'])

Definition at line 83 of file clientlist_tests.py.

00083 
00084     def test_adding_handles_hash_collision(self):
00085         def bad_hash(string):
00086             return '0' * 16
00087         self.list.hashfunc = bad_hash
00088         self.list.add_client('foo')
00089         self.list.add_client('bar')
00090         self.assertEqual(sorted(self.list.list_clients()), ['bar', 'foo'])
00091         self.assertNotEqual(self.list.get_client_id('bar'),
00092                             self.list.get_client_id('foo'))

Definition at line 93 of file clientlist_tests.py.

00093 
00094     def test_client_has_no_public_key_initially(self):
00095         self.list.add_client('foo')
00096         self.assertEqual(self.list.get_client_keyid('foo'), None)

Definition at line 39 of file clientlist_tests.py.

00039 
00040     def test_key_bytes_is_correct_length(self):
00041         self.assertEqual(self.list.key_bytes, 
00042                          len(self.list.key('foo', 12765, 0)))

Definition at line 52 of file clientlist_tests.py.

00052 
00053     def test_lists_no_clients_when_tree_does_not_exist(self):
00054         self.assertEqual(self.list.list_clients(), [])

Definition at line 102 of file clientlist_tests.py.

00102 
00103     def test_remove_client_keyid(self):
00104         self.list.add_client('foo')
00105         self.list.set_client_keyid('foo', 'cafebeef')
00106         self.list.set_client_keyid('foo', None)
00107         self.assertEqual(self.list.get_client_keyid('foo'), None)
00108 

Definition at line 69 of file clientlist_tests.py.

00069 
00070     def test_removed_client_has_no_keys(self):
00071         self.list.add_client('foo')
00072         client_id = self.list.get_client_id('foo')
00073         self.list.remove_client('foo')
00074         minkey = self.list.key('foo', client_id, 0)
00075         maxkey = self.list.key('foo', client_id, self.list.SUBKEY_MAX)
00076         pairs = list(self.list.tree.lookup_range(minkey, maxkey))
00077         self.assertEqual(pairs, [])

Definition at line 64 of file clientlist_tests.py.

00064 
00065     def test_removed_client_has_none_id(self):
00066         self.list.add_client('foo')
00067         self.list.remove_client('foo')
00068         self.assertEqual(self.list.get_client_id('foo'), None)
        

Definition at line 49 of file clientlist_tests.py.

00049 
00050     def test_reports_none_as_id_for_nonexistent_client(self):
00051         self.assertEqual(self.list.get_client_id('foo'), None)
        

Definition at line 97 of file clientlist_tests.py.

00097 
00098     def test_sets_client_keyid(self):
00099         self.list.add_client('foo')
00100         self.list.set_client_keyid('foo', 'cafebeef')
00101         self.assertEqual(self.list.get_client_keyid('foo'), 'cafebeef')

Definition at line 78 of file clientlist_tests.py.

00078 
00079     def test_twice_added_client_exists_only_once(self):
00080         self.list.add_client('foo')
00081         self.list.add_client('foo')
00082         self.assertEqual(self.list.list_clients(), ['foo'])

Definition at line 43 of file clientlist_tests.py.

00043 
00044     def test_unkey_unpacks_key_correctly(self):
00045         key = self.list.key('client name', 12765, 42)
00046         client_hash, client_id, subkey = self.list.unkey(key)
00047         self.assertEqual(client_id, 12765)
00048         self.assertEqual(subkey, 42)


Member Data Documentation

Definition at line 29 of file clientlist_tests.py.

Definition at line 31 of file clientlist_tests.py.

Definition at line 27 of file clientlist_tests.py.


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