File: test_hex_conversions_multihash.py

package info (click to toggle)
python-imagehash 4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,060 kB
  • sloc: python: 1,041; makefile: 81; sh: 31
file content (37 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from __future__ import absolute_import, division, print_function

import unittest

import imagehash

from .utils import TestImageHash


class Test (TestImageHash):
    def setUp(self):
        self.image = self.get_data_image()

    def test_hex_to_multi_hash(self):
        generated_hash = imagehash.crop_resistant_hash(
            self.image,
            # these arguments are required for a true multi image hash with multiple segments
            min_segment_size=500, segmentation_image_size=1000
        )
        string = str(generated_hash)
        emsg = ('Stringified multihash did not match original hash')
        self.assertEqual(
            generated_hash,
            imagehash.hex_to_multihash(string),
            emsg
        )
        string = '0026273b2b19550e,6286373334662535,6636192c47639573,999d6d67a3e82125,27a327c38191a4ad,938971382b328a46'
        emsg = ('Stringified multihash did not match hardcoded original hash')
        self.assertEqual(
            generated_hash,
            imagehash.hex_to_multihash(string),
            emsg
        )


if __name__ == '__main__':
    unittest.main()