Skip to content

Commit 17de864

Browse files
committed
Update ubuntu base image and fix tests, add heic/heif test image.
1 parent fd3dbbd commit 17de864

File tree

7 files changed

+20
-17
lines changed

7 files changed

+20
-17
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
language: python
2+
dist: focal
23
python:
34
- "3.7"
45
- "3.8"
56
- "3.9"
67
install:
7-
- sudo apt-get install -y libblas-dev liblapack-dev libatlas-base-dev gfortran libheif-dev
8+
- sudo apt-get install -y libblas-dev liblapack-dev libatlas-base-dev gfortran libffi-dev automake make libtool autoconf g++ m4 pkg-config
9+
- wget https://github.com/strukturag/libheif/releases/download/v1.10.0/libheif-1.10.0.tar.gz
10+
- tar xvf libheif-1.10.0.tar.gz && pushd libheif-1.10.0 && ./autogen.sh && ./configure --disable-dependency-tracking && make && sudo make install && popd && rm -rf libheif-1.10.0
811
- pip install --only-binary=numpy,scipy -r requirements.txt
912
- pip install -r requirements-test.txt
1013
script: pytest tests/test.py -v

duplicate_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _add_to_database(file_, hash_, file_size, image_size, capture_time, db):
173173

174174

175175
def _in_database(file, db):
176-
return db.count({"_id": file}) > 0
176+
return db.count_documents({"_id": file}) > 0
177177

178178

179179
def new_image_files(files, db):
@@ -214,7 +214,7 @@ def clear(db):
214214

215215

216216
def show(db):
217-
total = db.count()
217+
total = db.count_documents()
218218
pprint(list(db.find()))
219219
print("Total: {}".format(total))
220220

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ termcolor==1.1.0
1010
Werkzeug==1.0.1
1111
Flask-Cors==3.0.9
1212
pybktree==1.1
13-
git+https://github.com/david-poirier-csn/pyheif.git
13+
pyheif==0.5.1
-1.31 KB
Loading
27.7 KB
Loading

tests/images/u.heic

1.64 MB
Binary file not shown.

tests/test.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
def test_get_image_files():
12-
images = ['tests/images/u.jpg', 'tests/images/file.png', 'tests/images/file.gif', 'tests/images/file.tiff',
12+
images = ['tests/images/u.jpg', 'tests/images/u.heic', 'tests/images/file.png', 'tests/images/file.gif', 'tests/images/file.tiff',
1313
'tests/images/image.txt', 'tests/images/deeply/nested/different.jpg',
1414
'tests/images/deeply/nested/image/sideways.jpg', 'tests/images/deeply/nested/image/smaller.jpg']
1515
other = ['tests/images/not_image.txt', 'tests/images/not_image.jpb', 'README.md']
@@ -25,7 +25,7 @@ def test_hash_file():
2525
file, hash_, file_size, image_size, capture_time = result
2626

2727
assert file == image_name
28-
assert hash_ == '4b9e705db4450db6695cba149e2b2d65c3a950e13c7e8778e1cbda081e12a7eb'
28+
assert hash_ == '87d35b107818e5d7963a5d2869d4b4b6c3950a873c7ee11ed2790eba2da2b03d'
2929

3030
result = duplicate_finder.hash_file('tests/images/nothing.png')
3131
assert result is None
@@ -57,7 +57,7 @@ def test_hash_files_parallel():
5757

5858
file, hash_, file_size, image_size, capture_time = results[0]
5959
assert file == 'tests/images/u.jpg'
60-
assert hash_ == '4b9e705db4450db6695cba149e2b2d65c3a950e13c7e8778e1cbda081e12a7eb'
60+
assert hash_ == '87d35b107818e5d7963a5d2869d4b4b6c3950a873c7ee11ed2790eba2da2b03d'
6161

6262

6363
duplicate_finder.NUM_PROCESSES = 1
@@ -111,33 +111,33 @@ def test_add():
111111

112112
db_result = db.find_one({'_id' : file_name})
113113
assert db_result['_id'] == file_name
114-
assert db_result['hash'] == '4b9e705db4450db6695cba149e2b2d65c3a950e13c7e8778e1cbda081e12a7eb'
115-
assert db.count() > 0
114+
assert db_result['hash'] == '87d35b107818e5d7963a5d2869d4b4b6c3950a873c7ee11ed2790eba2da2b03d'
115+
assert db.count_documents() > 0
116116

117117

118118
def test_remove():
119119
db = mongomock.MongoClient().image_database.images
120120

121121
duplicate_finder.add(['tests'], db)
122-
assert db.count() > 0
122+
assert db.count_documents() > 0
123123
duplicate_finder.remove(['test'], db)
124-
assert db.count() > 0
124+
assert db.count_documents() > 0
125125

126126
duplicate_finder.remove(['tests'], db)
127-
assert db.count() == 0
127+
assert db.count_documents() == 0
128128

129129
duplicate_finder.remove(['tests'], db)
130-
assert db.count() == 0
130+
assert db.count_documents() == 0
131131

132132

133133
def test_clear():
134134
db = mongomock.MongoClient().image_database.images
135135

136136
duplicate_finder.add(['tests'], db)
137137

138-
assert db.count() > 0
138+
assert db.count_documents() > 0
139139
duplicate_finder.clear(db)
140-
assert db.count() == 0
140+
assert db.count_documents() == 0
141141

142142

143143
def test_find():
@@ -157,7 +157,7 @@ def test_find():
157157
def test_dedup():
158158
db = mongomock.MongoClient().image_database.images
159159
duplicate_finder.add(['tests'], db)
160-
assert db.count() == 8
160+
assert db.count_documents() == 9
161161

162162
dups = duplicate_finder.find(db, match_time=False)
163163
assert len(dups) == 2
@@ -174,7 +174,7 @@ def test_dedup():
174174
assert not os.path.exists(item['file_name'])
175175
assert os.path.exists(os.path.join('Trash', os.path.basename(item['file_name'])))
176176

177-
assert db.count() == 4
177+
assert db.count_documents() == 4
178178

179179
# Move files back
180180
for dup in dups:

0 commit comments

Comments
 (0)