Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
update tests for local changed files patch
Browse files Browse the repository at this point in the history
  • Loading branch information
richq committed Apr 6, 2015
1 parent 0d4f48a commit ff8679e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
16 changes: 7 additions & 9 deletions f2flickr/flickr2history.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ def convert_format(images, imageDir, historyFile):
- Size of file
"""
logging.debug('flickr2history: Started convert_format')
try:
user = flickr.test_login()
logging.debug(user.id)
except:
logging.error(sys.exc_info()[0])
return None

uploaded = shelve.open( historyFile )
num_images=len(images)
Expand All @@ -92,9 +86,13 @@ def convert_format(images, imageDir, historyFile):
logging.debug('Photo %s cannot be found from history file' % image)
num_not_found += 1
continue
stats = os.stat(full_image_path)
file_mtime=stats.st_mtime
file_size=stats.st_size
try:
stats = os.stat(full_image_path)
file_mtime=stats.st_mtime
file_size=stats.st_size
except OSError:
file_mtime = 0
file_size = 0
uploaded[ image] = ( photo_id, file_mtime, file_size )
uploaded[ photo_id ] = image
num_converted += 1
Expand Down
25 changes: 17 additions & 8 deletions test/test_tags2set.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
import fakeflickr
import shelve
import f2flickr.flickr2history
import f2flickr.tags2set
import f2flickr.configuration

def setSubsetsTrue():
tmp = open('uploadr.ini', 'r')
Expand Down Expand Up @@ -41,7 +44,6 @@ def setUp(self):
sample = open('uploadr.ini.sample', 'r')
inifile.write(sample.read())
inifile.close()
import f2flickr.tags2set

def tearDown(self):
os.unlink('uploadr.ini')
Expand All @@ -52,25 +54,36 @@ def testSetIsUpdated(self):
First upload 20 photos, then upload some more, up to 44
The 44 should be in the set.
"""
import f2flickr.tags2set
historyFile = tempfile.mktemp()
fakeuploaded = shelve.open(historyFile)
for i in range(1, 21):
fakeuploaded[str(i)] = 'random/img%d.jpg' % i
fakeuploaded[str(i)] = '/random/img%d.jpg' % i

addinvert(fakeuploaded)
images = [k for k in fakeuploaded if k.startswith('/random')]
fakeuploaded.close()
f2flickr.flickr2history.convert_format(images,
'',
historyFile)

uploaded = [str(r) for r in range(1, 21)]
f2flickr.tags2set.createSets(uploaded, historyFile)
user = fakeflickr.fakelogin()
self.assertEquals(1, len(user.getPhotosets()))
ps = user.getPhotosets()[0]
photos = ps.getPhotos()
self.assertEquals(20, len(photos))

fakeuploaded = shelve.open(historyFile)
fakeuploaded.clear()
for i in range(1, 45):
fakeuploaded[str(i)] = 'random/img%d.jpg' % i
fakeuploaded[str(i)] = '/random/img%d.jpg' % i
addinvert(fakeuploaded)
images = [k for k in fakeuploaded if k.startswith('/random')]
fakeuploaded.close()
f2flickr.flickr2history.convert_format(images,
'',
historyFile)

uploaded = [str(r) for r in range(22, 45)]
f2flickr.tags2set.createSets(uploaded, historyFile)
Expand Down Expand Up @@ -98,7 +111,6 @@ def testOnlySubsFalse(self):
"""
Check only_sub_sets = false
"""
import f2flickr.tags2set
uploaded, historyFile = self.createHistory()
f2flickr.configuration.configdict = f2flickr.configuration.ConfigDict()
f2flickr.tags2set.createSets(uploaded, historyFile)
Expand All @@ -112,8 +124,6 @@ def testOnlySubsTrue(self):
"""
Check only_sub_sets = false
"""
import f2flickr.tags2set
import f2flickr.configuration
uploaded, historyFile = self.createHistory()
setSubsetsTrue()
f2flickr.configuration.configdict = f2flickr.configuration.ConfigDict()
Expand All @@ -127,7 +137,6 @@ def testIssue35(self):
"""
Create 2 simple sets, shouldn't create 3
"""
import f2flickr.tags2set
historyFile = tempfile.mktemp()
fakeuploaded = shelve.open(historyFile)
setSubsetsTrue()
Expand Down

0 comments on commit ff8679e

Please sign in to comment.