Skip to content

Commit

Permalink
adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
Guinsly Mondesir committed Feb 10, 2016
1 parent 96fc2e0 commit abd25e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import pyexifinfo as p
p.ver() #retrieve your ExifTool version
filename = 'python-logo.png'
p.get_json(filename) #retrieve a json representation of this file exif
```
```json
=>
[{u'File:FilePermissions': u'rw-rw-r--', u'PNG:Interlace': u'Noninterlaced', u'S
ourceFile': u'/home/laptop/python-logo.png', u'PNG:ColorType': u'RGB with Alpha', u'File:MIMEType': u'image/png',u'File:FileAccessDate': u'2015:07:20 16:37:22-04:00', u'File:FileModifyDate': u'2014:12:12 20:55:59-05:00', u'File:FileSize': u'9.9 kB', u'PNG:ImageWidth': 290, u'File:FileType': u'PNG', u'File:FileName': u'python-logo.png', u'PNG:Compression': u'Deflate/Inflate', u'PNG:PixelsPerUnitY': 2835, u'PNG:PixelsPerUnitX': 2835, u'PNG:ImageHeight': 82, u'PNG:PixelUnits': u'Meters', u'File:Directory': u'/home/laptop', u'File:FileInodeChangDate': u'2015:07:20 16:37:22-04:00', u'PNG:Filter': u'Adaptive', u'PNG:BitDepth': 8, u'Composite:ImageSize': u'290x82', u'ExifTool:ExifToolVersion': 9.46}]
Expand All @@ -31,9 +33,6 @@ result = get_csv(filename)
result = get_xml(filename)
result = fileType(filename)
result = mimeType(filename)
result = imageSize(filename)
result = imageWidth(filename)
result = imageHeight(filename)
```


3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ result = get_csv(filename)
result = get_xml(filename)
result = fileType(filename)
result = mimeType(filename)
result = imageSize(filename)
result = imageWidth(filename)
result = imageHeight(filename)



4 changes: 4 additions & 0 deletions pyexifinfo/pyexifinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def get_csv(filename):
filename = os.path.abspath(filename)
s = command_line(['exiftool', '-G', '-csv', '-sort', filename])
if s:
#convert bytes to string
s = s.decode('utf-8')
return s
else:
return 0
Expand All @@ -66,6 +68,8 @@ def get_xml(filename):
filename = os.path.abspath(filename)
s = command_line(['exiftool', '-G', '-X', '-sort', filename])
if s:
#convert bytes to string
s = s.decode('utf-8')
return s
else:
return 0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup(
name='PyExifinfo',

version='0.1.2',
version='0.1.5',

description="Yet another simple wrapper for ExifTool",

Expand Down Expand Up @@ -41,4 +41,4 @@
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),


)
)
25 changes: 14 additions & 11 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import pyexifinfo as p
import os
import csv


# content of test_sample.py
#tested with Pytest
#
#
# python logo (MIT)
image = 'python-logo-master-v3-TM.png'

def test_version_is_greater_than_8():
""" test the version is greater than 8 """
a = p.ver()
Expand All @@ -17,6 +20,14 @@ def test_get_json():
a = p.get_json("tests/"+image)
assert len(a[0]) == 25

def test_get_csv():
a = p.get_csv("tests/"+image)
assert a[0:10] == "SourceFile"

def test_get_xml():
a = p.get_xml("tests/"+image)
assert a[0:5] == "<?xml"

def test_get_fileType():
a = p.fileType("tests/"+image)
assert a.lower() == 'png'
Expand All @@ -28,11 +39,3 @@ def test_get_mimeType():
def test_get_imageSize():
a = p.imageSize("tests/"+image)
assert a.lower() == '601x203'

def test_get_imageWidh():
a = p.imageWidth("tests/"+image)
assert a == 601

def test_get_imageHeight():
a = p.imageHeight("tests/"+image)
assert a == 203

0 comments on commit abd25e9

Please sign in to comment.