def test_import_screencaptures(self): """it should be possible to run this at any time, even if the dedicated temp directory does not exist yet. """ event = Event.objects.get(title='Test event') # First, put some pictures in the temp directory for this event. temp_dir = os.path.join( tempfile.gettempdir(), settings.SCREENCAPTURES_TEMP_DIRECTORY_NAME ) if not os.path.isdir(temp_dir): os.mkdir(temp_dir) # expect there to be a directory with the event's ID directory_name = '%s_%s' % (event.id, event.slug) event_temp_dir = os.path.join(temp_dir, directory_name) if not os.path.isdir(event_temp_dir): os.mkdir(event_temp_dir) # sample_jpg = self.sample_jpg # sample_jpg2 = self.sample_jpg2 shutil.copyfile( self.sample_jpg, os.path.join(event_temp_dir, 'screencap-01.jpg') ) shutil.copyfile( self.sample_jpg2, os.path.join(event_temp_dir, 'screencap-02.jpg') ) # Also create an empty broken file dest = os.path.join(event_temp_dir, 'screencap-03.jpg') with open(dest, 'wb') as f: f.write('') # An extra one that won't get imported because the name isn't # matching. shutil.copyfile( self.sample_jpg2, os.path.join(event_temp_dir, 'otherfile.jpg') ) videoinfo.import_screencaptures() ok_(not os.path.isdir(event_temp_dir)) ok_(os.path.isdir(temp_dir)) eq_(Picture.objects.filter(event=event).count(), 2)
def test_import_screencaptures(self): """it should be possible to run this at any time, even if the dedicated temp directory does not exist yet. """ event = Event.objects.get(title='Test event') # First, put some pictures in the temp directory for this event. temp_dir = os.path.join( tempfile.gettempdir(), settings.SCREENCAPTURES_TEMP_DIRECTORY_NAME ) if not os.path.isdir(temp_dir): os.mkdir(temp_dir) # expect there to be a directory with the event's ID directory_name = '%s_%s' % (event.id, event.slug) event_temp_dir = os.path.join(temp_dir, directory_name) if not os.path.isdir(event_temp_dir): os.mkdir(event_temp_dir) # sample_jpg = self.sample_jpg # sample_jpg2 = self.sample_jpg2 shutil.copyfile( self.sample_jpg, os.path.join(event_temp_dir, 'screencap-01.jpg') ) shutil.copyfile( self.sample_jpg2, os.path.join(event_temp_dir, 'screencap-02.jpg') ) # Also create an empty broken file dest = os.path.join(event_temp_dir, 'screencap-03.jpg') with open(dest, 'wb') as f: f.write('') # An extra one that won't get imported because the name isn't # matching. shutil.copyfile( self.sample_jpg2, os.path.join(event_temp_dir, 'otherfile.jpg') ) videoinfo.import_screencaptures() ok_(not os.path.isdir(event_temp_dir)) ok_(os.path.isdir(temp_dir)) eq_(Picture.objects.filter(event=event).count(), 2)
def test_import_screencaptures_empty(self): """it should be possible to run this at any time, even if the dedicated temp directory does not exist yet. """ assert not Picture.objects.all().count() videoinfo.import_screencaptures() ok_(not Picture.objects.all().count())
def test_import_screencaptures_empty(self): """it should be possible to run this at any time, even if the dedicated temp directory does not exist yet. """ assert not Picture.objects.all().count() videoinfo.import_screencaptures() ok_(not Picture.objects.all().count())