コード例 #1
0
 def test_fuzzy_update(self):
     test_state = fuzzy_new()
     fuzzy_update(
         test_state,
         b'This test fuzzy hash string',
         len(b'This test fuzzy hash string')
     )
     self.assertEqual(test_state.contents.total_size, 27)
コード例 #2
0
 def test_fuzzy_new_raise(self):
     with mock.patch(
         'pyssdeep.ssdeep_wrapper.fuzzy_lib.fuzzy_new'
     ) as fuzzy_new_mock:
         fuzzy_new_mock.return_value = None
         with self.assertRaises(FuzzyHashError) as context:
             test_state = fuzzy_new()
     self.assertTrue('-1' in str(context.exception))
コード例 #3
0
 def test_fuzzy_new(self):
     test_state = fuzzy_new()
     self.assertEqual(test_state.contents.bhstart, 0)
     self.assertEqual(test_state.contents.bhend, 1)
     self.assertEqual(test_state.contents.bhendlimit, 30)
     self.assertEqual(test_state.contents.total_size, 0)
     self.assertEqual(test_state.contents.reduce_border, 192)
     self.assertEqual(test_state.contents.flags, 0)
     self.assertEqual(test_state.contents.rollmask, 0)
コード例 #4
0
 def test_fuzzy_set_total_input_length_raise(self):
     test_state = fuzzy_new()
     with mock.patch(
         'pyssdeep.ssdeep_wrapper.fuzzy_lib.fuzzy_set_total_input_length'
     ) as fuzzy_set_total_input_length_mock:
         fuzzy_set_total_input_length_mock.return_value = -1
         with self.assertRaises(FuzzyHashError) as context:
             fuzzy_set_total_input_length(test_state, 1000)
     self.assertTrue('-1' in str(context.exception))
コード例 #5
0
 def test_fuzzy_update_raise(self):
     test_state = fuzzy_new()
     with mock.patch(
         'pyssdeep.ssdeep_wrapper.fuzzy_lib.fuzzy_update'
     ) as fuzzy_update_mock:
         fuzzy_update_mock.return_value = -1
         with self.assertRaises(FuzzyHashError) as context:
             fuzzy_update(
                 test_state,
                 b'This test fuzzy hash string',
                 len(b'This test fuzzy hash string')
             )
     self.assertTrue('-1' in str(context.exception))
コード例 #6
0
 def test_fuzzy_clone(self):
     test_state = fuzzy_new()
     test_state.contents.bh[0].digest = b'test_fuzzy_digest'
     test_state_copy = fuzzy_clone(test_state)
     test_state_copy.contents.bh[0].digest = b'test_fuzzy_copy_digest'
     self.assertEqual(
         test_state_copy.contents.bh[0].digest,
         b'test_fuzzy_copy_digest'
     )
     self.assertEqual(
         test_state.contents.bh[0].digest,
         b'test_fuzzy_digest'
     )
コード例 #7
0
 def test_fuzzy_digest(self):
     test_state = fuzzy_new()
     self.assertEqual(fuzzy_digest(test_state, 0), '3::')
コード例 #8
0
 def test_fuzzy_set_total_input_length(self):
     test_state = fuzzy_new()
     fuzzy_set_total_input_length(test_state, 1000)
     self.assertEqual(test_state.contents.bhendlimit, 4)