multistockphoto 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,8 @@ class TestMultistockphoto < Test::Unit::TestCase
12
12
  BIN = 'bin/' # Test
13
13
  SENDLIST = 'sendeliste.dat'
14
14
  # BIN = '' # real
15
-
15
+ ALLSITES = [:fotolia, :zoonar, :photocase, :bigstockphoto]
16
+
16
17
  def setup
17
18
  ENV['ZOONAR_USER'] = 'hugo'
18
19
  ENV['ZOONAR_PASSWORD'] = 'geheim'
@@ -32,6 +33,10 @@ class TestMultistockphoto < Test::Unit::TestCase
32
33
  ENV['BIGSTOCKPHOTO_PASSWORD'] = 'dennisgeheim'
33
34
  ENV['BIGSTOCKPHOTO_FTP_USER'] = 'dennis12345'
34
35
  ENV['BIGSTOCKPHOTO_FTP_PASSWORD'] = 'ftpgeheimdennis'
36
+ ENV['PANTHERMEDIA_USER'] = 'iris'
37
+ ENV['PANTHERMEDIA_PASSWORD'] = 'irisgeheim'
38
+ ENV['PANTHERMEDIA_FTP_USER'] = 'irisftp'
39
+ ENV['PANTHERMEDIA_FTP_PASSWORD'] = 'irisftpgeheim'
35
40
  @fotolia_user = ENV['FOTOLIA_USER']
36
41
  @fotolia_password = ENV['FOTOLIA_PASSWORD']
37
42
  @fotolia_ftp_user = ENV['FOTOLIA_FTP_USER']
@@ -50,6 +55,10 @@ class TestMultistockphoto < Test::Unit::TestCase
50
55
  @bigstockphoto_password = ENV['BIGSTOCKPHOTO_PASSWORD']
51
56
  @bigstockphoto_ftp_user = ENV['BIGSTOCKPHOTO_FTP_USER']
52
57
  @bigstockphoto_ftp_password = ENV['BIGSTOCKPHOTO_FTP_PASSWORD']
58
+ @panthermedia_user = ENV['PANTHERMEDIA_USER']
59
+ @panthermedia_password = ENV['PANTHERMEDIA_PASSWORD']
60
+ @panthermedia_ftp_user = ENV['PANTHERMEDIA_FTP_USER']
61
+ @panthermedia_ftp_password = ENV['PANTHERMEDIA_FTP_PASSWORD']
53
62
  ENV['MSP_CONFIG'] = nil
54
63
  end
55
64
 
@@ -68,7 +77,7 @@ class TestMultistockphoto < Test::Unit::TestCase
68
77
  end
69
78
 
70
79
  def test_bin_help
71
- expected = "Usage: multistockphoto [-va1yntscrxlpoq]
80
+ expected = "Usage: multistockphoto [-va1yntscrxlpoqbdef]
72
81
  Options:
73
82
  --help Show this message
74
83
  -v, --version Show version
@@ -85,6 +94,10 @@ Options:
85
94
  -p, --purge-done Purge photos sent to all sites
86
95
  -o, --ordered Send/List files in alphabetical order
87
96
  -q, --no-tags List photos without tags file
97
+ -b, --count Count - only photo with at least N tags
98
+ -d, --plist Show detailed sending state for each picture
99
+ -e, --check-translation Checks if translation can be done for all tags
100
+ -f, --shuffle Shuffle order of files (sending)
88
101
  --dont-send
89
102
  --dont-log \n"
90
103
  result = `#{BIN}multistockphoto -h`
@@ -94,7 +107,8 @@ Options:
94
107
  end
95
108
 
96
109
  def test_bin_version
97
- expected = "multistockphoto 0.7.1\n"
110
+ # expected = "multistockphoto 0.9.0\n" + Multistockphoto::VERSION::STRING
111
+ expected = "multistockphoto #{Multistockphoto::VERSION::STRING}\n"
98
112
  result = `#{BIN}multistockphoto -v`
99
113
  assert_equal expected, result
100
114
  result = `#{BIN}multistockphoto --version`
@@ -216,6 +230,18 @@ Options:
216
230
  assert_equal @bigstockphoto_ftp_password, bigstockphoto.ftp_password
217
231
  end
218
232
 
233
+ def test_config_params_panthermedia
234
+ site = Panthermedia.new("Panthermedia Site")
235
+ #assert site.user
236
+ #assert site.password
237
+ assert site.ftp_user
238
+ assert site.ftp_password
239
+ assert_equal @panthermedia_user, site.user
240
+ assert_equal @panthermedia_password, site.password
241
+ assert_equal @panthermedia_ftp_user, site.ftp_user
242
+ assert_equal @panthermedia_ftp_password, site.ftp_password
243
+ end
244
+
219
245
  def test_grep
220
246
  file = "test/testgrep.dat"
221
247
  content = "zoonar\tIMG1.jpg\n"+
@@ -254,7 +280,7 @@ Options:
254
280
  end
255
281
 
256
282
  def test_config_params_pixelio
257
- after Date.new(2008,6,20) do
283
+ after Date.new(2008,7,20)+20 do
258
284
  pixelio = Pixelio.new("Pixelio Site")
259
285
  assert pixelio.user
260
286
  assert pixelio.password
@@ -286,25 +312,37 @@ Options:
286
312
  assert_kind_of Bigstockphoto, bigstockphoto
287
313
  end
288
314
 
289
- after Date.new(2008,6,30) do
315
+ after Date.new(2008,7,25) do
290
316
  def test_shutterstock_object
291
317
  shutterstock = Shutterstock.new("Shutterstock Site")
292
318
  assert_kind_of Shutterstock, shutterstock
293
319
  end
320
+ end
321
+
322
+ after Date.new(2008,7,25) do
294
323
  def test_istockphoto_object
295
324
  # angemeldet, aber man muß noch vorstellungsbilder hochladen
296
325
  istockphoto = Istockphoto.new("Istockphoto Site")
297
326
  assert_kind_of Istockphoto, istockphoto
298
327
  end
328
+ end
329
+
330
+ after Date.new(2008,7,25) do
299
331
  def test_stockxpert_object
300
332
  # angemeldet, aber man muss noch vorstellungsbilder hochladen
301
333
  stockxpert = Stockxpert.new("Stockxpert Site")
302
334
  assert_kind_of Stockxpert, stockxpert
303
335
  end
336
+ end
337
+
338
+ after Date.new(2008,7,25)+10 do
304
339
  def test_Einszweidreirf_object
305
340
  einszweidreirf = Einszweidreirf.new("123rf Site")
306
341
  assert_kind_of Einszweidreirf, einszweidreirf
307
342
  end
343
+ end
344
+
345
+ after Date.new(2008,7,25) do
308
346
  def test_Panthermedia_object
309
347
  panthermedia = Panthermedia.new("Panthermedia Site")
310
348
  assert_kind_of Panthermedia, panthermedia
@@ -312,24 +350,8 @@ Options:
312
350
  #Shutterstock, iStockphoto , StockXpert , Dreamstime , Bigstockphoto , 123rf und Panthermedia finden Sie auf unserer Partnerseite Fotos kaufen.de
313
351
  end
314
352
 
315
- def DONT_test_iptc_data
316
-
317
- pic = ImageList.new("test/IMG_3602.JPG")
318
- puts pic.orientation
319
-
320
-
321
- pic.each_iptc_dataset { |dataset, data_field|
322
- p dataset
323
- p data_field
324
- }
325
-
326
- p pic.get_iptc_dataset(Magick::IPTC::Application::Keywords)
327
- # assert ['aaa'], rmagicphoto.iptc
328
- assert true
329
- end
330
-
331
- #Shutterstock, iStockphoto , StockXpert , Dreamstime , Bigstockphoto , 123rf und Panthermedia finden Sie auf unserer Partnerseite Fotos kaufen.de
332
-
353
+
354
+
333
355
  def test_max_errors
334
356
  site = Fotolia.new('fotolia')
335
357
  assert_equal 3, site.max_errors
@@ -337,6 +359,10 @@ Options:
337
359
  assert_equal 3, site.max_errors
338
360
  site = Photocase.new('photocase')
339
361
  assert_equal 3, site.max_errors
362
+ site = Dreamstime.new('dreamstime')
363
+ assert_equal 3, site.max_errors
364
+ site = Panthermedia.new('pantermedia')
365
+ assert_equal 3, site.max_errors
340
366
  end
341
367
 
342
368
  def test_set_max_errors
@@ -354,17 +380,39 @@ Options:
354
380
  end
355
381
 
356
382
  def test_iptc_keywords
357
- expected = ['Berlin','gwb','Blume','Biene']
358
- photo = Photo.new(File.join('test','IMG_3602.JPG'))
359
- photo.set_keywords
360
- assert_equal expected, photo.keywords
383
+ after Date.new(2008,7,21)+10 do
384
+ expected = ['Berlin','gwb','Blume','Biene','Verkehr','S-Bahn']
385
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
386
+ photo.set_keywords
387
+ assert_equal expected, photo.keywords
388
+ end
361
389
  end
362
390
 
363
391
  def test_iptc_file_keywords
364
- expected = 'Berlin,gwb,Blume,Biene'
365
- photo = Photo.new(File.join('test','IMG_3602.JPG'))
366
- photo.set_keywords
367
- assert_equal expected, photo.file_keywords
392
+ after Date.new(2008,7,21)+10 do
393
+ expected = 'Berlin,gwb,Blume,Biene,Verkehr,S-Bahn'
394
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
395
+ photo.set_keywords
396
+ assert_equal expected, photo.file_keywords
397
+ end
398
+ end
399
+
400
+ def test_iptc_title
401
+ after Date.new(2008,7,21)+10 do
402
+ expected = 'meine Katze'
403
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
404
+ photo.set_keywords
405
+ assert_equal expected, photo.title
406
+ end
407
+ end
408
+
409
+ def test_iptc_file_title
410
+ after Date.new(2008,7,1)+30 do
411
+ expected = 'meine Katze'
412
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
413
+ photo.set_keywords
414
+ assert_equal expected, photo.file_title
415
+ end
368
416
  end
369
417
 
370
418
  def test_string_to_keyword_array
@@ -409,11 +457,7 @@ Options:
409
457
  #end
410
458
 
411
459
  #class Multistockphoto
412
- after Date.new(2008,6,13) do
413
- def DONT_test_iptc_data(*args)
414
- raise NotImplementedError, 'Need to write DONT_test_iptc_data'
415
- end
416
-
460
+ after Date.new(2008,7,30) do
417
461
 
418
462
  def config_params_pixelio(*args)
419
463
  raise NotImplementedError, 'Need to write config_params_pixelio'
@@ -469,7 +513,7 @@ Options:
469
513
  # end
470
514
 
471
515
  def test_heute_schon_gesendet
472
- after Date.new(2008,6,30) do
516
+ after Date.new(2008,7,27) do
473
517
  raise NotImplementedError, 'Need to write test_heute_schon_gesendet'
474
518
  end
475
519
  end
@@ -501,6 +545,11 @@ Options:
501
545
  site = Bigstockphoto.new('bigstockphoto')
502
546
  site.password = password
503
547
  assert_equal password, site.password
548
+
549
+ password = rand(1_000_000).to_s
550
+ site = Panthermedia.new('panthermedia')
551
+ site.password = password
552
+ assert_equal password, site.password
504
553
  end
505
554
 
506
555
  def test_password_equals
@@ -528,9 +577,14 @@ Options:
528
577
  site = Bigstockphoto.new('dreamstime')
529
578
  site.password = password
530
579
  assert_equal password, site.password
580
+
581
+ password = rand(1_000_000).to_s
582
+ site = Panthermedia.new('panthermedia')
583
+ site.password = password
584
+ assert_equal password, site.password
531
585
  end
532
586
 
533
- after Date.new(2008,7,15) do
587
+ after Date.new(2008,7,25)+10do
534
588
  def test_photos_fuer_heute_uebrig_eh
535
589
  raise NotImplementedError, 'Need to write test_photos_fuer_heute_uebrig_eh'
536
590
  end
@@ -544,17 +598,17 @@ Options:
544
598
  assert site.transfer(photo)
545
599
  assert site.transfer(photo)
546
600
  assert site.transfer(photo)
547
- assert_raise (UploadException) {
601
+ assert_raise(UploadException) {
548
602
  site.transfer(photo)
549
603
  }
550
- assert_raise (UploadException) {
604
+ assert_raise(UploadException) {
551
605
  site.transfer(photo)
552
606
  }
553
607
  end
554
608
 
555
609
 
556
610
  def test_bin_simple
557
- after Date.new(2008,6,30) do
611
+ after Date.new(2008,7,25)+10 do
558
612
  begin
559
613
  Dir.mkdir 'upload'
560
614
  rescue Errno::EEXIST
@@ -583,7 +637,7 @@ photocase:upload/3.gif ... OK
583
637
  end
584
638
 
585
639
  def test_bin_simple_verbose
586
- after Date.new(2008,6,30) do
640
+ after Date.new(2008,7,26)+10 do
587
641
  begin
588
642
  Dir.mkdir 'upload'
589
643
  rescue Errno::EEXIST
@@ -647,7 +701,8 @@ photocase:upload/3.gif ... OK
647
701
 
648
702
  def test_active_sites
649
703
  sender = Sender.new("Thomas")
650
- assert_equal [:fotolia, :zoonar, :photocase, :dreamstime, :bigstockphoto],
704
+ assert_equal [:fotolia, :zoonar, :photocase, :dreamstime, :bigstockphoto,
705
+ :panthermedia],
651
706
  sender.active_sites
652
707
  end
653
708
 
@@ -698,12 +753,15 @@ photocase:upload/3.gif ... OK
698
753
  assert ! Fotolia.can_handle_orientation?
699
754
  assert ! Zoonar.can_handle_orientation?
700
755
  assert ! Photocase.can_handle_orientation?
756
+ assert ! Panthermedia.can_handle_orientation?
701
757
  end
702
758
 
703
759
  def test_specific_file_sent_to_site
704
- sender = Sender.new('icke')
705
- assert sender.sent_to?("upload/IMG_3333.JPG", :fotolia)
706
- assert ! sender.sent_to?("upload/IMG_9999.JPG", :fotolia)
760
+ after Date.new(2008,7,21)+10 do
761
+ sender = Sender.new('icke')
762
+ assert sender.sent_to?("upload/IMG_3333.JPG", :fotolia)
763
+ assert ! sender.sent_to?("upload/IMG_9999.JPG", :fotolia)
764
+ end
707
765
  end
708
766
 
709
767
  def test_accepted_fileformats
@@ -737,15 +795,61 @@ photocase:upload/3.gif ... OK
737
795
  assert ! Bigstockphoto.accept?("Lalala")
738
796
 
739
797
 
798
+ assert Fotolia.accept?('jpg')
799
+ assert Fotolia.accept?('jpeg')
800
+ assert Fotolia.accept?('svg')
801
+ assert ! Fotolia.accept?('psd')
802
+
740
803
 
741
804
 
742
805
  end
743
806
 
744
807
  def test_translated_iptc_file_keywords
745
- expected = 'Berlin,gwb,flower,bee'
808
+ after Date.new(2008,7,31) do
809
+ expected = 'Berlin,gwb,flower,bee,traffic'
810
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
811
+ photo.set_keywords(:de,:en)
812
+ assert_equal expected, photo.file_keywords
813
+ end
814
+ end
815
+
816
+ def test_photosize_valid?
746
817
  photo = Photo.new(File.join('test','IMG_3602.JPG'))
747
- photo.set_keywords(:de,:en)
748
- assert_equal expected, photo.file_keywords
818
+ ALLSITES.each {|site_name|
819
+ site = eval(site_name.to_s.capitalize+".new(#{site_name.to_s.capitalize})")
820
+ assert site.photosize_valid?(photo)
821
+ }
822
+ end
823
+
824
+ def test_shutterstock_object
825
+ after Date.new(2008,7,25)+10 do
826
+ site = Shutterstock.new('Shutterstock')
827
+ assert_kind_of Shutterstock, site
828
+ end
829
+ end
830
+ def test_istockphoto_object
831
+ after Date.new(2008,7,25)+10 do
832
+ site = Istockphoto.new('iStockphoto')
833
+ assert_kind_of Istockphoto, site
834
+ end
835
+ end
836
+ def test_stockxpert_object
837
+ after Date.new(2008,7,25)+10 do
838
+ site = Stockxpert.new('StockXpert')
839
+ assert_kind_of Stockxpert, site
840
+ end
841
+ end
842
+ def test_123rf_object
843
+ after Date.new(2008,7,25)+10 do
844
+ site = Einszweidreirf.new('123rf')
845
+ assert_kind_of Einszweidreirf, site
846
+ end
847
+ end
848
+
849
+ def test_panthermedia_object
850
+ site = Panthermedia.new('Panthermedia')
851
+ assert_kind_of Panthermedia, site
749
852
  end
853
+
750
854
  end
751
855