コード例 #1
0
ファイル: test_log.py プロジェクト: bbengfort/cloudscope
    def test_log_index(self):
        """
        Test finding the index of a version in a log
        """
        versions = CharacterSequence(upper=True)
        log = WriteLog()

        for term in xrange(5):
            for _ in xrange(10):
                log.append(versions.next(), term)

        versions.reset()
        for idx in xrange(1, len(log)):
            version = versions.next()
            self.assertEqual(log.index(version), idx)
            self.assertEqual(log[log.index(version)].version, version)
コード例 #2
0
    def test_log_index(self):
        """
        Test finding the index of a version in a log
        """
        versions = CharacterSequence(upper=True)
        log = WriteLog()

        for term in xrange(5):
            for _ in xrange(10):
                log.append(versions.next(), term)

        versions.reset()
        for idx in xrange(1, len(log)):
            version = versions.next()
            self.assertEqual(log.index(version), idx)
            self.assertEqual(log[log.index(version)].version, version)
コード例 #3
0
ファイル: test_log.py プロジェクト: bbengfort/cloudscope
    def test_log_index_term(self):
        """
        Test finding the index of a version in a log with a term
        """
        log = WriteLog()
        log.append('A', 0)
        log.append('B', 1)
        log.append('C', 1)
        log.append('D', 2)

        self.assertIsNone(log.index('A', 1))
        self.assertIsNone(log.index('B', 2))
        self.assertIsNone(log.index('C', 0))
        self.assertIsNone(log.index('D', 1))
        self.assertEqual(log.index('A', 0), 1)
        self.assertEqual(log.index('B', 1), 2)
        self.assertEqual(log.index('C', 1), 3)
        self.assertEqual(log.index('D', 2), 4)
コード例 #4
0
    def test_log_index_term(self):
        """
        Test finding the index of a version in a log with a term
        """
        log = WriteLog()
        log.append('A', 0)
        log.append('B', 1)
        log.append('C', 1)
        log.append('D', 2)

        self.assertIsNone(log.index('A', 1))
        self.assertIsNone(log.index('B', 2))
        self.assertIsNone(log.index('C', 0))
        self.assertIsNone(log.index('D', 1))
        self.assertEqual(log.index('A', 0), 1)
        self.assertEqual(log.index('B', 1), 2)
        self.assertEqual(log.index('C', 1), 3)
        self.assertEqual(log.index('D', 2), 4)