From 71b1e9f0edf662bd76dcc1493f3e858f253dabd8 Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Mon, 12 Sep 2016 22:23:24 -0700 Subject: [PATCH] gh-40 Add tests to increase coverage in geolocation and photo module --- elodie/media/photo.py | 23 ----------------------- elodie/tests/geolocation_test.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/elodie/media/photo.py b/elodie/media/photo.py index ee2287b..e89c032 100644 --- a/elodie/media/photo.py +++ b/elodie/media/photo.py @@ -10,7 +10,6 @@ from __future__ import absolute_import import imghdr import os import re -import subprocess import time from datetime import datetime from re import compile @@ -38,28 +37,6 @@ class Photo(Media): # We only want to parse EXIF once so we store it here self.exif = None - def get_duration(self): - """Get the duration of a photo in seconds. Uses ffmpeg/ffprobe. - - :returns: str or None for a non-photo file - """ - if(not self.is_valid()): - return None - - source = self.source - result = subprocess.Popen( - ['ffprobe', source], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT - ) - for key in result.stdout.readlines(): - if 'Duration' in key: - return re.search( - '(\d{2}:\d{2}.\d{2})', - key - ).group(1).replace('.', ':') - return None - def get_date_taken(self): """Get the date which the photo was taken. diff --git a/elodie/tests/geolocation_test.py b/elodie/tests/geolocation_test.py index 02ab5e3..7642ba8 100644 --- a/elodie/tests/geolocation_test.py +++ b/elodie/tests/geolocation_test.py @@ -32,6 +32,20 @@ def test_decimal_to_dms(): assert target_decimal_value == check_value, '%s does not match %s' % (check_value, target_decimal_value) +def test_dms_to_decimal_positive_sign(): + decimal = geolocation.dms_to_decimal(10, 20, 100, 'NE') + assert helper.isclose(decimal, 10.3611111111) + + decimal = geolocation.dms_to_decimal(10, 20, 100, 'ne') + assert helper.isclose(decimal, 10.3611111111) + +def test_dms_to_decimal_negative_sign(): + decimal = geolocation.dms_to_decimal(10, 20, 100, 'SW') + assert helper.isclose(decimal, -10.3611111111) + + decimal = geolocation.dms_to_decimal(10, 20, 100, 'sw') + assert helper.isclose(decimal, -10.3611111111) + def test_dms_string_latitude(): for x in range(0, 5):