Esempio n. 1
0
 def test_reset_character_sequence(self):
     """
     Ensure that a sequence can be reset
     """
     sequence = CharacterSequence()
     for idx in xrange(27): sequence.next()
     self.assertEqual(sequence.value, "aa")
     sequence.reset()
     self.assertEqual(sequence.next(), "a")
Esempio n. 2
0
 def test_reset_character_sequence(self):
     """
     Ensure that a sequence can be reset
     """
     sequence = CharacterSequence()
     for idx in xrange(27):
         sequence.next()
     self.assertEqual(sequence.value, "aa")
     sequence.reset()
     self.assertEqual(sequence.next(), "a")
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
    def test_log_remove(self):
        """
        Test the remove of an item from a log
        """
        log = WriteLog()
        versions = CharacterSequence(upper=True)

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

        loglen = len(log)
        versions.reset()
        for idx in xrange(1, loglen):
            version = versions.next()
            self.assertEqual(version, log.remove(version), "log must return the removed version")
            self.assertEqual(len(log), loglen-idx, "log must decrease in size")
            self.assertNotIn(version, log, "log must not contain version")
Esempio n. 6
0
    def test_log_remove(self):
        """
        Test the remove of an item from a log
        """
        log = WriteLog()
        versions = CharacterSequence(upper=True)

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

        loglen = len(log)
        versions.reset()
        for idx in xrange(1, loglen):
            version = versions.next()
            self.assertEqual(version, log.remove(version),
                             "log must return the removed version")
            self.assertEqual(len(log), loglen - idx,
                             "log must decrease in size")
            self.assertNotIn(version, log, "log must not contain version")