Ejemplo n.º 1
0
 def test_reproducability_of_hashing(self):
     """ Test reproducability of block hashing with history """
     gen = RK_hash_generator(BUFFERSIZE, HASHRANGE)
     assert_equal(self.hgen.hash_block_with_history('1234567890123456'),
                  self.hgen.hash_block_with_history('1234567890123456'))  # using the same generator
     assert_equal(self.hgen.hash_block_with_history('1234567890123456'),
                  gen.hash_block_with_history('1234567890123456'))  # using other generator
Ejemplo n.º 2
0
 def test_init(self):
     """ Test initialisation of the Rabin & Karp generator """
     # Test instatiation of class variables
     test_gen = RK_hash_generator(BUFFERSIZE, HASHRANGE)
     assert_equal(test_gen.block_size, BUFFERSIZE)
     assert_equal(test_gen.prev_hash, 0)
     assert_equal(test_gen.base, 10)
     assert_equal(test_gen.chars, None)
     assert_equal(test_gen.hash_range, HASHRANGE)
Ejemplo n.º 3
0
 def test_compare_hash_block_against_incremental(self):
     """ Compare hash block generation versus incremental hash generation """
     gen = RK_hash_generator(BUFFERSIZE, HASHRANGE)
     hash1 = gen.hash_block('2345678901234567')
     self.hgen.hash_block_with_history('1234567890123456')
     hash2 = self.hgen.incremental('7')
     assert_equal(hash1, hash2)
     hash1 = gen.hash_block('3456789012345678')
     hash2 = self.hgen.incremental('8')
     assert_equal(hash1, hash2)
Ejemplo n.º 4
0
 def test_incremental_with_history(self):
     """ Running increment method after hashing block with history """
     gen = RK_hash_generator(BUFFERSIZE, HASHRANGE)
     gen.hash_block_with_history('1234567890123456')
     gen.incremental('7')
Ejemplo n.º 5
0
 def test_incremental_without_history(self):
     """ Raise exception when using incremental without history established """
     gen = RK_hash_generator(BUFFERSIZE, HASHRANGE)
     gen.hash_block('1234567890123456')
     gen.incremental('7')
Ejemplo n.º 6
0
 def test_invalid_init_hashrange_string(self):
     """ Instatiating RK hash generator with invalid hash range, string instead of integer """
     test_gen = RK_hash_generator(BUFFERSIZE, 'bytearray')
Ejemplo n.º 7
0
 def test_invalid_init_blocksize_string(self):
     """ Instatiating RK hash generator with invalid blocksize, string instead of integer """
     test_gen = RK_hash_generator('bytearray', HASHRANGE)
Ejemplo n.º 8
0
 def test_invalid_init_one_parameter(self):
     """ Test invalid Rabin & Karp generator class instantiation with no hash range specified """
     test_gen = RK_hash_generator(BUFFERSIZE)
Ejemplo n.º 9
0
 def test_invalid_init_no_paramaters(self):
     """ Test invalid Rabin & Karp generator class instantiation with no parameters """
     test_gen = RK_hash_generator()
Ejemplo n.º 10
0
 def setup_class(self):
     """ Initial configuration of TestKRFingerprinting, used by all methods """
     self.hgen = RK_hash_generator(BUFFERSIZE, HASHRANGE)