Пример #1
0
    def test_deserialize_error_length(self):
        data1 = decodehexstr("032422")
        data2 = decodehexstr("032422032422032422032422")

        with self.assertRaises(DeserializationException):
            LogIndexEntrySerializer.deserialize(data1)
        with self.assertRaises(DeserializationException):
            LogIndexEntrySerializer.deserialize(data2)
Пример #2
0
 def test_deserialize_error_length(self):
     data1 = decodehexstr("032422")
     data2 = decodehexstr("032422032422032422032422")
     
     with self.assertRaises(DeserializationException):
         LogIndexEntrySerializer.deserialize(data1)
     with self.assertRaises(DeserializationException):
         LogIndexEntrySerializer.deserialize(data2)
Пример #3
0
    def test_deserialize_logindex_write(self):
        log_index = LogIndexEntrySerializer.deserialize(
            decodehexstr("03020a5f8201"))

        self.assertEquals(
            log_index,
            LogIndexEntry(LogIndexEntry.WRITE, 34234242, needs_commit=True))
Пример #4
0
    def test_deserialize_logindex_begin_tx(self):
        log_index = LogIndexEntrySerializer.deserialize(
            decodehexstr("010000000001"))

        self.assertEquals(
            log_index, LogIndexEntry(LogIndexEntry.BEGIN_TX,
                                     needs_commit=True))
Пример #5
0
    def test_serialize_logindex_write(self):
        log_index = LogIndexEntry(LogIndexEntry.WRITE, 34234242, needs_commit=True)
        
        serialized = LogIndexEntrySerializer.serialize(log_index)

        self.assertEquals(serialized, 
                          decodehexstr("03020a5f8201"))
Пример #6
0
    def test_serialize_logindex_end_tx(self):
        log_index = LogIndexEntry(LogIndexEntry.END_TX, needs_commit=False)
        
        serialized = LogIndexEntrySerializer.serialize(log_index)

        self.assertEquals(serialized, 
                          decodehexstr("020000000000"))
Пример #7
0
    def test_serialize_logindex_begin_tx(self):
        log_index = LogIndexEntry(LogIndexEntry.BEGIN_TX, needs_commit=True)
        
        serialized = LogIndexEntrySerializer.serialize(log_index)

        self.assertEquals(serialized, 
                          decodehexstr("010000000001"))
Пример #8
0
    def test_deserialize_logindex_end_tx(self):
        log_index = LogIndexEntrySerializer.deserialize(
            decodehexstr("020000000000"))

        self.assertEquals(
            log_index, LogIndexEntry(LogIndexEntry.END_TX, needs_commit=False))