-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_PriusImageCache.py
58 lines (41 loc) · 1.55 KB
/
test_PriusImageCache.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pytest
from datetime import datetime, timedelta
from abc import ABC, ABCMeta, abstractmethod
from PriusImageCache import Deduplication, PathDeduplication, ImageDeduplication
path1 = "./time_id.jpg"
newPath1 = "./laterTime_id.jpg"
path2 = "./car1.jpg"
image_hash = '068309071b5b49490096090f2530ffff'
expected_hash = '068309071b5b49490096090f2530ffff'
@pytest.fixture(scope="module")
def path_dedup():
return PathDeduplication()
def image_dedup():
return ImageDeduplication()
def test_instance(path_dedup):
assert (isinstance(path_dedup, PathDeduplication))
def test_get_image_hash(path_dedup):
result_hash = path_dedup.get_image_hash(path1)
return(image_hash == result_hash)
def test_get_hash(path_dedup):
path_dedup.put_hash(path1)
result_hash = path_dedup.get_hash(path1)
assert result_hash == expected_hash
def test_put_hash(path_dedup):
path_dedup.put_hash(path1)
result_hash = path_dedup.get_hash(path1)
assert result_hash == expected_hash
def test_compare_images_when_duplicate(path_dedup):
result = path_dedup.compare_images(path1, path1)
assert result
def test_compare_images_when_not_duplicate(path_dedup):
result = path_dedup.compare_images(path1, path2)
assert result is False
def test_is_image_duplicate_when_duplicate(path_dedup):
path_dedup.put_hash(path1)
result = path_dedup.is_image_duplicate(path1)
assert result
def test_is_image_duplicate_when_not_duplicate(path_dedup):
path_dedup.put_hash(path1)
result = path_dedup.is_image_duplicate(newPath1)
assert result is False