~didrocks/ubuntuone-client/dont-suffer-zg-crash

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_tritcask.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2011-01-25 16:42:52 UTC
  • mto: This revision was merged to the branch mainline in revision 64.
  • Revision ID: james.westby@ubuntu.com-20110125164252-rl1pybasx1nsqgoy
Tags: upstream-1.5.3
ImportĀ upstreamĀ versionĀ 1.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from operator import attrgetter
31
31
 
32
 
from contrib.testing.testcase import BaseTwistedTestCase, MementoHandler
 
32
from contrib.testing.testcase import BaseTwistedTestCase
 
33
from ubuntuone.devtools.handlers import MementoHandler
33
34
from ubuntuone.syncdaemon.tritcask import (
34
35
    TOMBSTONE,
35
36
    LIVE,
592
593
            self.assertEqual('foo1', key)
593
594
 
594
595
 
 
596
class HintEntryTest(BaseTestCase):
 
597
    """Tests for HintEntry class."""
 
598
 
 
599
    def test_header_property(self):
 
600
        """Test the header property."""
 
601
        tstamp = time.time()
 
602
        entry = HintEntry(tstamp, len('foo'), 0, len('bar'), 100, 'foo')
 
603
        self.assertEqual((entry.tstamp, entry.key_sz, entry.row_type,
 
604
                          entry.value_sz, entry.value_pos), entry.header)
 
605
 
 
606
 
595
607
class LowLevelTest(BaseTestCase):
596
608
    """Tests for low level methods and functions.
597
609
 
1065
1077
        self.assertRaises(ValueError, self.db.delete, 0, u'foobar')
1066
1078
        self.assertRaises(ValueError, self.db.delete, 0, object())
1067
1079
 
 
1080
    def test_keys(self):
 
1081
        """Test for the keys() method."""
 
1082
        # add some values
 
1083
        key, data = self.build_data()
 
1084
        self.db.put(0, key, data)
 
1085
        key, data = self.build_data()
 
1086
        self.db.put(0, key, data)
 
1087
        self.assertEqual(self.db._keydir.keys(), self.db.keys())
 
1088
 
 
1089
    def test__contains__(self):
 
1090
        """Test for __contains__ method."""
 
1091
        key, data = self.build_data()
 
1092
        self.db.put(0, key, data)
 
1093
        key1, data1 = self.build_data()
 
1094
        self.db.put(0, key1, data1)
 
1095
        self.assertTrue((0, key) in self.db._keydir)
 
1096
        self.assertTrue((0, key) in self.db)
 
1097
        self.assertTrue((0, key1) in self.db._keydir)
 
1098
        self.assertTrue((0, key1) in self.db)
1068
1099
 
1069
1100
class MergeTests(BaseTestCase):
1070
1101