windows timezone problem in filesystem test fixed

This commit is contained in:
zserg 2016-01-27 18:28:18 +04:00
parent 6e6f88c336
commit 582d609023
2 changed files with 27 additions and 10 deletions

View File

@ -225,7 +225,8 @@ class Media(object):
if(constants.debug is True):
print '%s -config "%s" -xmp-elodie:Album="%s" "%s"' % (exiftool, exiftool_config, name, source) # noqa
process_output = subprocess.Popen(
[exiftool, '-config', exiftool_config, '-xmp-elodie:Album=%s'%(name),source],
'%s -config "%s" -xmp-elodie:Album="%s" "%s"' %
(exiftool, exiftool_config, name, source),
stdout=subprocess.PIPE,
shell=True
)

View File

@ -4,6 +4,9 @@ import sys
import re
import shutil
from datetime import datetime
from datetime import timedelta
import time
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
@ -12,9 +15,22 @@ from elodie.filesystem import FileSystem
from elodie.media.media import Media
from elodie.media.photo import Photo
from elodie.media.video import Video
from nose.plugins.skip import SkipTest
os.environ['TZ'] = 'GMT'
if os.name == 'nt':
tz_shift = (datetime.fromtimestamp(0) -
datetime.utcfromtimestamp(0)).seconds/3600
else:
tz_shift = 0
def path_tz_fix(s_path):
#some_prefix2015-12-05_00-59-26-with-title-some-title.jpg
m = re.search('(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})',s_path)
t_date = datetime.fromtimestamp(time.mktime(time.strptime(m.group(0), '%Y-%m-%d_%H-%M-%S')))
s_date_fix = (t_date-timedelta(hours=tz_shift)).strftime('%Y-%m-%d_%H-%M-%S')
return re.sub('\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}',s_date_fix,s_path)
def test_create_directory_success():
filesystem = FileSystem()
@ -128,14 +144,14 @@ def test_get_file_name_plain():
media = Photo(helper.get_file('plain.jpg'))
file_name = filesystem.get_file_name(media)
assert file_name == '2015-12-05_00-59-26-plain.jpg', file_name
assert file_name == path_tz_fix('2015-12-05_00-59-26-plain.jpg'), file_name
def test_get_file_name_with_title():
filesystem = FileSystem()
media = Photo(helper.get_file('with-title.jpg'))
file_name = filesystem.get_file_name(media)
assert file_name == '2015-12-05_00-59-26-with-title-some-title.jpg', file_name
assert file_name == path_tz_fix('2015-12-05_00-59-26-with-title-some-title.jpg'), file_name
def test_get_folder_name_by_date():
filesystem = FileSystem()
@ -195,7 +211,7 @@ def test_process_file_plain():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Unknown Location','2015-12-05_00-59-26-photo.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Unknown Location','2015-12-05_00-59-26-photo.jpg')) in destination, destination
def test_process_file_with_title():
filesystem = FileSystem()
@ -215,7 +231,7 @@ def test_process_file_with_title():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Unknown Location','2015-12-05_00-59-26-photo-some-title.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Unknown Location','2015-12-05_00-59-26-photo-some-title.jpg')) in destination, destination
def test_process_file_with_location():
filesystem = FileSystem()
@ -235,7 +251,7 @@ def test_process_file_with_location():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Sunnyvale','2015-12-05_00-59-26-photo.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Sunnyvale','2015-12-05_00-59-26-photo.jpg')) in destination, destination
def test_process_file_with_location_and_title():
filesystem = FileSystem()
@ -255,7 +271,7 @@ def test_process_file_with_location_and_title():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Sunnyvale','2015-12-05_00-59-26-photo-some-title.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Sunnyvale','2015-12-05_00-59-26-photo-some-title.jpg')) in destination, destination
def test_process_file_with_album():
filesystem = FileSystem()
@ -275,7 +291,7 @@ def test_process_file_with_album():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo.jpg')) in destination, destination
def test_process_file_with_album_and_title():
filesystem = FileSystem()
@ -295,7 +311,7 @@ def test_process_file_with_album_and_title():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo-some-title.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo-some-title.jpg')) in destination, destination
def test_process_file_with_album_and_title_and_location():
filesystem = FileSystem()
@ -315,4 +331,4 @@ def test_process_file_with_album_and_title_and_location():
assert origin_checksum is not None, origin_checksum
assert origin_checksum == destination_checksum, destination_checksum
assert os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo-some-title.jpg') in destination, destination
assert path_tz_fix(os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo-some-title.jpg')) in destination, destination