multistockphoto 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/config.yaml ADDED
@@ -0,0 +1,41 @@
1
+ ---
2
+ :active_sites:
3
+ - :fotolia
4
+ - :zoonar
5
+ - :photocase
6
+ - :dreamstime
7
+ - :bigstockphoto
8
+ - :panthermedia
9
+ :zoonar:
10
+ :user: 'hugo'
11
+ :password: 'lalala'
12
+ :total_per_day: 10
13
+ :fotolia:
14
+ :user: 'hugo'
15
+ :password: 'lalala'
16
+ :ftp_user: '200507099'
17
+ :ftp_password: 'hugolalala'
18
+ :total_per_day: 11
19
+ :photocase:
20
+ :user: 'hugo'
21
+ :password: 'lalala'
22
+ :total_per_day: 12
23
+ :dreamstime:
24
+ :user: 'martha'
25
+ :password: 'mageheim'
26
+ :ftp_user: 'martha12345'
27
+ :ftp_password: 'ftpgeheimmartha'
28
+ :total_per_day: 1
29
+ :bigstockphoto:
30
+ :user: 'dennis'
31
+ :password: 'dennisgeheim'
32
+ :ftp_user: 'dennis12345'
33
+ :ftp_password: 'ftpgeheimdennis'
34
+ :total_per_day: 1
35
+ :panthermedia:
36
+ :user: 'iris'
37
+ :password: 'irisgeheim'
38
+ :ftp_user: 'irisftp'
39
+ :ftp_password: 'irisftpgeheim'
40
+ :total_per_day: 1
41
+
@@ -1,24 +1,57 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
1
 
4
2
  module Multistockphoto
5
- end
3
+ #
4
+ # :stopdoc:
5
+ VERSION = '0.9.2'
6
+ # LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
+ # PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
+ # :startdoc:
9
+ #
10
+ # # Returns the version string for the library.
11
+ # #
12
+ # def self.version
13
+ # VERSION
14
+ # end
15
+ #
16
+ # # Returns the library path for the module. If any arguments are given,
17
+ # # they will be joined to the end of the libray path using
18
+ # # <tt>File.join</tt>.
19
+ # #
20
+ # def self.libpath( *args )
21
+ # args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
22
+ # end
23
+ #
24
+ # # Returns the lpath for the module. If any arguments are given,
25
+ # # they will be joined to the end of the path using
26
+ # # <tt>File.join</tt>.
27
+ # #
28
+ # def self.path( *args )
29
+ # args.empty? ? PATH : ::File.join(PATH, args.flatten)
30
+ # end
31
+ #
32
+ # # Utility method used to require all files ending in .rb that lie in the
33
+ # # directory below this file that has the same name as the filename passed
34
+ # # in. Optionally, a specific _directory_ name can be passed in such that
35
+ # # the _filename_ does not have to be equivalent to the directory.
36
+ # #
37
+ # def self.require_all_libs_relative_to( fname, dir = nil )
38
+ # dir ||= ::File.basename(fname, '.*')
39
+ # search_me = ::File.expand_path(
40
+ # ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
41
+ #
42
+ # Dir.glob(search_me).sort.each {|rb| require rb}
43
+ # end
44
+ #
45
+ end # module Multistockphoto
46
+ #
47
+ #Multistockphoto.require_all_libs_relative_to(__FILE__)
6
48
 
7
- require 'multistockphoto/version'
8
- require 'multistockphoto/generic_site'
9
- require 'multistockphoto/multistockphoto'
10
- require 'multistockphoto/photo'
11
- #require 'multistockphoto/config'
12
49
  require 'multistockphoto/sender'
13
-
50
+ #require 'multistockphoto/photo'
51
+ require 'multistockphoto/generic_site'
14
52
  require 'multistockphoto/site_fotolia'
15
- require 'multistockphoto/site_zoonar'
16
- #require 'multistockphoto/site_aldi'
17
- require 'multistockphoto/site_photocase'
18
53
  require 'multistockphoto/site_dreamstime'
19
- require 'multistockphoto/site_bigstockphoto'
20
54
  require 'multistockphoto/site_panthermedia'
21
-
22
-
23
- require 'multistockphoto/upload_exception'
24
- require 'multistockphoto/mock_zoonar'
55
+ require 'multistockphoto/site_photocase'
56
+ require 'multistockphoto/site_zoonar'
57
+ # EOF
Binary file
@@ -1,3 +1,28 @@
1
+ require 'yaml'
2
+
3
+ #--
4
+ #TODO: fix für komischen recursive Array join Fehler
5
+ # wieder entfernen, wenn das kein Problem mehr ist
6
+ require "monitor"
7
+ module Net
8
+ class FTP
9
+ include MonitorMixin
10
+ def sendport(host, port)
11
+ af = (@sock.peeraddr)[0]
12
+ if af == "AF_INET"
13
+ cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
14
+ elsif af == "AF_INET6"
15
+ cmd = sprintf("EPRT |2|%s|%d|", host, port)
16
+ else
17
+ raise FTPProtoError, host
18
+ end
19
+ voidcmd(cmd)
20
+ end
21
+ private :sendport
22
+ end
23
+ end
24
+ #++
25
+
1
26
  class GenericSite
2
27
  attr_reader :name
3
28
  attr_accessor :user, :password, :max_errors
@@ -49,7 +74,7 @@ class GenericSite
49
74
  #TODO: leere Zeilen ignorieren
50
75
  site, photo_file, time = line.chomp.split("\t")
51
76
 
52
- date = Date.parse(time)
77
+ date = Date.parse(time)
53
78
 
54
79
  key = [site, date]
55
80
  if count[key]==nil
@@ -1,3 +1,4 @@
1
+ # Klasse Aldi war nur ein Experiment und wird wieder gelöscht, da man auf deren Site keinen Account anlegen kann, sondern nur seine Bilder hochladen, und von diesen Abzüge bestellen kann. Das läßt sich schwer automatisieren und ist auch nicht der eigentliche Zweck dieses gems
1
2
  class Aldi < GenericSite
2
3
 
3
4
  def initialize(name)
@@ -79,4 +80,4 @@ class Aldi < GenericSite
79
80
  def html_out(body,html_file)
80
81
  File.open(html_file,"w") {|f| f.print body}
81
82
  end
82
- end
83
+ end
@@ -1,5 +1,6 @@
1
1
  require 'net/ftp'
2
2
 
3
+ # Klasse zum Senden an http://www.bigstockphoto.com/
3
4
  class Bigstockphoto < GenericSite
4
5
 
5
6
  @@errors = 0
@@ -118,4 +119,4 @@ if already_sent_site?(photo,SITENAME)
118
119
  true #TODO: pruefen!
119
120
  end
120
121
 
121
- end # class
122
+ end # class
@@ -1,5 +1,6 @@
1
1
  require 'net/ftp'
2
2
 
3
+ # Klasse zum Senden an http://www.dreamstime.com/
3
4
  class Dreamstime < GenericSite
4
5
 
5
6
  @@errors = 0
@@ -121,4 +122,4 @@ class Dreamstime < GenericSite
121
122
  true
122
123
  end
123
124
 
124
- end # class
125
+ end # class
@@ -1,5 +1,35 @@
1
1
  require 'net/ftp'
2
+ #--
3
+ #TODO: fix für komischen recursive Array join Fehler
4
+ # wieder entfernen, wenn das kein Problem mehr ist
5
+ require "monitor"
6
+ module Net
7
+ class FTP
8
+ include MonitorMixin
9
+ def sendport(host, port)
10
+ af = (@sock.peeraddr)[0]
11
+ if af == "AF_INET"
12
+ # original: cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
13
+ #(host.split(".") + port.divmod(256)).join(",")
14
+ tmp = ''
15
+ (host.split(".") + port.divmod(256)).each do |x|
16
+ tmp << "#{x},"
17
+ end
18
+ tmp = tmp[0..-2]
19
+ cmd = "PORT " + tmp #(host.split(".") + port.divmod(256)).join(",")
20
+ elsif af == "AF_INET6"
21
+ cmd = sprintf("EPRT |2|%s|%d|", host, port)
22
+ else
23
+ raise FTPProtoError, host
24
+ end
25
+ voidcmd(cmd)
26
+ end
27
+ private :sendport
28
+ end
29
+ end
30
+ #++
2
31
 
32
+ # Klasse zum Senden an http://www.fotolia.de
3
33
  class Fotolia < GenericSite
4
34
 
5
35
  @@errors = 0
@@ -64,7 +94,7 @@ class Fotolia < GenericSite
64
94
  files =ftp.list('*')
65
95
  #p files
66
96
  ftp.close
67
- rescue Errno::EPIPE, Net::FTPTempError
97
+ rescue Errno::EPIPE, Net::FTPTempError, Net::FTPPermError
68
98
  raise UploadException
69
99
  end
70
100
  end
@@ -10,6 +10,7 @@ dass ich erstmal darauf verzichtet habe, Istockphoto hier mit aufzunehmen.
10
10
  Aufgeschoben ist aber nicht aufgehoben. Ich werde irgenwann mal darauf zurückkommen.
11
11
 
12
12
  =end
13
- class Itockphoto < GenericSite
13
+ # Klasse zum Senden an http://deutsch.istockphoto.com/index.php?view=full
14
+ class Istockphoto < GenericSite
14
15
 
15
- end # class
16
+ end # class
@@ -11,6 +11,7 @@ Wichtig:
11
11
 
12
12
  TODO: Groesse der Datei testen - ist aber momentan kein kritischer Wert fuer mich
13
13
  =end
14
+ # Klasse zum Senden an http://www.panthermedia.net/
14
15
  class Panthermedia < GenericSite
15
16
 
16
17
  @@errors = 0
@@ -129,4 +130,4 @@ class Panthermedia < GenericSite
129
130
  true
130
131
  end
131
132
 
132
- end # class
133
+ end # class
@@ -1,6 +1,7 @@
1
- require 'rubygems'
2
- require 'mechanize'
1
+ #require 'rubygems'
2
+ #require 'mechanize'
3
3
 
4
+ # Klasse zum Senden an http://www.photocase.de/de/photobrowser.asp
4
5
  class Photocase < GenericSite
5
6
  SITENAME = 'photocase'
6
7
  @@errors = 0
@@ -68,7 +69,8 @@ class Photocase < GenericSite
68
69
  end
69
70
  end
70
71
  # form = page.forms.first #TODO: besser nach Name
71
- form = page.forms[1] #TODO: es ist jetzt das zweite Formular
72
+ # form = page.forms[1] #TODO: es ist jetzt das zweite Formular
73
+ form = page.forms[2] #TODO: es ist jetzt das dritte Formular
72
74
  # form['loginForm[Username]'] = @config[:zoonar][:user]
73
75
  # form['loginForm[Password]'] = @config[:zoonar][:password]
74
76
  form['UserName'] = @config[:photocase][:user]
@@ -2,6 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'mechanize'
4
4
 
5
+ # Klasse zum Senden an http://www.zoonar.de/
5
6
  class Zoonar < GenericSite
6
7
  SITENAME = 'zoonar'
7
8
  @@errors = 0
@@ -1,9 +1,9 @@
1
- module Multistockphoto #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 9
5
- TINY = 0
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
1
+ #module Multistockphoto #:nodoc:
2
+ #module VERSION #:nodoc:
3
+ #MAJOR = 0
4
+ #MINOR = 9
5
+ #TINY = 0
6
+ #
7
+ #STRING = [MAJOR, MINOR, TINY].join('.')
8
+ #end
9
+ #end
data/sendeliste.dat ADDED
File without changes
@@ -0,0 +1,7 @@
1
+
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+
4
+ describe Multistockphoto do
5
+ end
6
+
7
+ # EOF
@@ -0,0 +1,16 @@
1
+
2
+ require File.expand_path(
3
+ File.join(File.dirname(__FILE__), %w[.. lib multistockphoto]))
4
+
5
+ Spec::Runner.configure do |config|
6
+ # == Mock Framework
7
+ #
8
+ # RSpec uses it's own mocking framework by default. If you prefer to
9
+ # use mocha, flexmock or RR, uncomment the appropriate line:
10
+ #
11
+ # config.mock_with :mocha
12
+ # config.mock_with :flexmock
13
+ # config.mock_with :rr
14
+ end
15
+
16
+ # EOF
data/test/IMG_3602.JPG ADDED
Binary file
@@ -0,0 +1,6 @@
1
+ require 'test/unit'
2
+ #require File.dirname(__FILE__) + '/../lib/multistockphoto'
3
+
4
+ def after(d)
5
+ yield if DateTime.now > d
6
+ end
@@ -0,0 +1,906 @@
1
+ #require "./"+File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ require 'grep'
4
+ include Grep
5
+ require 'RMagick'
6
+ include Magick
7
+ require 'multistockphoto/generic_site'
8
+ require 'multistockphoto/site_fotolia'
9
+ require 'multistockphoto/site_zoonar'
10
+ require 'multistockphoto/site_bigstockphoto'
11
+ require 'multistockphoto/site_dreamstime'
12
+ require 'multistockphoto/site_istockphoto'
13
+ require 'multistockphoto/site_panthermedia'
14
+ require 'multistockphoto/site_photocase'
15
+ require 'multistockphoto/mock_zoonar'
16
+ require 'multistockphoto/upload_exception'
17
+ require 'multistockphoto/sender'
18
+ require 'multistockphoto/photo'
19
+ #require 'multistockphoto'
20
+ require 'test/unit'
21
+
22
+ def after(d)
23
+ yield if DateTime.now > d
24
+ end
25
+
26
+ #TODO:
27
+ if RUBY_VERSION >= "1.9.0"
28
+ require 'date'
29
+ end
30
+
31
+ class TestMultistockphoto < Test::Unit::TestCase
32
+
33
+ REAL_TRANSFER = false
34
+ BIN = 'bin/' # Test
35
+ SENDLIST = 'sendeliste.dat'
36
+ # BIN = '' # real
37
+ ALLSITES = [:fotolia, :zoonar, :photocase, :bigstockphoto]
38
+
39
+ def setup
40
+ ENV['ZOONAR_USER'] = 'hugo'
41
+ ENV['ZOONAR_PASSWORD'] = 'geheim'
42
+ ENV['ZOONAR_USER'] = 'hugo'
43
+ ENV['ZOONAR_PASSWORD'] = 'lalala'
44
+ ENV['FOTOLIA_USER'] = 'hugo'
45
+ ENV['FOTOLIA_PASSWORD'] = 'lalala'
46
+ ENV['FOTOLIA_FTP_USER'] = '200507099'
47
+ ENV['FOTOLIA_FTP_PASSWORD'] = 'hugolalala'
48
+ ENV['PHOTOCASE_USER'] = 'hugo'
49
+ ENV['PHOTOCASE_PASSWORD'] = 'lalala'
50
+ ENV['DREAMSTIME_USER'] = 'martha'
51
+ ENV['DREAMSTIME_PASSWORD'] = 'mageheim'
52
+ ENV['DREAMSTIME_FTP_USER'] = 'martha12345'
53
+ ENV['DREAMSTIME_FTP_PASSWORD'] = 'ftpgeheimmartha'
54
+ ENV['BIGSTOCKPHOTO_USER'] = 'dennis'
55
+ ENV['BIGSTOCKPHOTO_PASSWORD'] = 'dennisgeheim'
56
+ ENV['BIGSTOCKPHOTO_FTP_USER'] = 'dennis12345'
57
+ ENV['BIGSTOCKPHOTO_FTP_PASSWORD'] = 'ftpgeheimdennis'
58
+ ENV['PANTHERMEDIA_USER'] = 'iris'
59
+ ENV['PANTHERMEDIA_PASSWORD'] = 'irisgeheim'
60
+ ENV['PANTHERMEDIA_FTP_USER'] = 'irisftp'
61
+ ENV['PANTHERMEDIA_FTP_PASSWORD'] = 'irisftpgeheim'
62
+ @fotolia_user = ENV['FOTOLIA_USER']
63
+ @fotolia_password = ENV['FOTOLIA_PASSWORD']
64
+ @fotolia_ftp_user = ENV['FOTOLIA_FTP_USER']
65
+ @fotolia_ftp_password = ENV['FOTOLIA_FTP_PASSWORD']
66
+ @zoonar_user = ENV['ZOONAR_USER']
67
+ @zoonar_password = ENV['ZOONAR_PASSWORD']
68
+ @aldi_user = ENV['ALDI_USER']
69
+ @aldi_password = ENV['ALDI_PASSWORD']
70
+ @photocase_user = ENV['PHOTOCASE_USER']
71
+ @photocase_password = ENV['PHOTOCASE_PASSWORD']
72
+ @dreamstime_user = ENV['DREAMSTIME_USER']
73
+ @dreamstime_password = ENV['DREAMSTIME_PASSWORD']
74
+ @dreamstime_ftp_user = ENV['DREAMSTIME_FTP_USER']
75
+ @dreamstime_ftp_password = ENV['DREAMSTIME_FTP_PASSWORD']
76
+ @bigstockphoto_user = ENV['BIGSTOCKPHOTO_USER']
77
+ @bigstockphoto_password = ENV['BIGSTOCKPHOTO_PASSWORD']
78
+ @bigstockphoto_ftp_user = ENV['BIGSTOCKPHOTO_FTP_USER']
79
+ @bigstockphoto_ftp_password = ENV['BIGSTOCKPHOTO_FTP_PASSWORD']
80
+ @panthermedia_user = ENV['PANTHERMEDIA_USER']
81
+ @panthermedia_password = ENV['PANTHERMEDIA_PASSWORD']
82
+ @panthermedia_ftp_user = ENV['PANTHERMEDIA_FTP_USER']
83
+ @panthermedia_ftp_password = ENV['PANTHERMEDIA_FTP_PASSWORD']
84
+ ENV['MSP_CONFIG'] = nil
85
+ end
86
+
87
+ def test_objects
88
+ f = Fotolia.new 'fotolia'
89
+ assert_kind_of Fotolia, f
90
+ b = Bigstockphoto.new 'bigstockphoto'
91
+ assert_kind_of Bigstockphoto, b
92
+ d = Dreamstime.new 'dreamstime'
93
+ assert_kind_of Dreamstime, d
94
+ i = Istockphoto.new 'istockphoto'
95
+ assert_kind_of Istockphoto, i
96
+ p = Panthermedia.new 'panthermedia'
97
+ assert_kind_of Panthermedia, p
98
+ p = Photocase.new 'photocase'
99
+ assert_kind_of Photocase, p
100
+ z = Zoonar.new 'zoonar'
101
+ assert_kind_of Zoonar, z
102
+ end
103
+
104
+ after Date.new(2009,8,1) do
105
+ def test_bin_check_orientation
106
+ #expected = "test/IMG_3602.JPG:\tTopLeftOrientation\n"
107
+ expected = "test/IMG_3602.JPG:\tlandscape\n"
108
+
109
+ result = `#{BIN}multistockphoto --check-orientation test/IMG_3602.JPG`
110
+ assert_equal expected, result
111
+
112
+ result = `#{BIN}multistockphoto -c test/IMG_3602.JPG`
113
+ assert_equal expected, result
114
+
115
+ result = `#{BIN}multistockphoto -c test/IMG_5880.JPG`
116
+ assert_equal "test/IMG_5880.JPG:\tportrait\n", result
117
+ end
118
+
119
+ def test_bin_help
120
+ expected = "Usage: multistockphoto [-va1yntscrxlpoqbdef]
121
+ Options:
122
+ --help Show this message
123
+ -v, --version Show version
124
+ -a, --send-all Send all files
125
+ -1, --tags-only Send only photos with keywords
126
+ -y, --verbose Verbose output
127
+ -n, --not-sent Count not sent files per site
128
+ -t, --total-transfers Dont't send more than N photos in total
129
+ -s, --total-per-site Send no more than N photos per site
130
+ -c, --check-orientation Displays the orientiation of photo files
131
+ -r, --rotate file [file2 ...] Rotate a photo file 90 degrees to the left
132
+ -x, --stats Displays statistics
133
+ -l, --list-done List photos sent to all sites
134
+ -p, --purge-done Purge photos sent to all sites
135
+ -o, --ordered Send/List files in alphabetical order
136
+ -q, --no-tags List photos without tags file
137
+ -b, --count Count - only photo with at least N tags
138
+ -d, --plist Show detailed sending state for each picture
139
+ -e, --check-translation Checks if translation can be done for all tags
140
+ -f, --shuffle Shuffle order of files (sending)
141
+ --dont-send
142
+ --dont-log \n"
143
+ result = `#{BIN}multistockphoto -h`
144
+ assert_equal expected, result
145
+ result = `#{BIN}multistockphoto --help`
146
+ assert_equal expected, result
147
+ end
148
+
149
+ end
150
+
151
+ after Date.new(2009,8,1) do
152
+ def test_bin_version
153
+ # expected = "multistockphoto 0.9.0\n" + Multistockphoto::VERSION::STRING
154
+ expected = "multistockphoto #{Multistockphoto::VERSION}\n"
155
+ result = `#{BIN}multistockphoto -v`
156
+ assert_equal expected, result
157
+ result = `#{BIN}multistockphoto --version`
158
+ assert_equal expected, result
159
+ end
160
+
161
+ end
162
+ def test_fotolia
163
+ fotolia = Fotolia.new("Fotolia")
164
+ fotolia.ftp_user = @fotolia_ftp_user
165
+ fotolia.ftp_password = @fotolia_ftp_password
166
+
167
+ assert_kind_of Fotolia, fotolia
168
+ assert_equal "Fotolia", fotolia.name
169
+
170
+ fotolia.user = @fotolia_user
171
+ fotolia.password = @fotolia_password
172
+
173
+ assert_equal @fotolia_user, fotolia.user
174
+ assert_equal @fotolia_password, fotolia.password
175
+
176
+ end
177
+
178
+ def test_photo
179
+ photo = Photo.new("123.jpg")
180
+ assert_kind_of Photo, photo
181
+ assert_equal "123.jpg", photo.filename
182
+ end
183
+ after Date.new(2009,8,1) do
184
+
185
+ def test_fotolia_transfer_1
186
+ if REAL_TRANSFER
187
+ fotolia = Fotolia.new("Fotolia")
188
+ fotolia.user = @fotolia_user
189
+ fotolia.password = @fotolia_password
190
+ photo = Photo.new("test/1234.jpg")
191
+ #assert fotolia.transfer(photo)
192
+ #TODO: zwei Gruende, warum das fehlschlagen kann:
193
+ # 1. Datei nicht vorhanden
194
+ # 2. Argument kein Photo-Objekt
195
+ # => bessere Tests
196
+ # assert_raise (RuntimeError) {
197
+ # fotolia.transfer("123.jpg")
198
+ # }
199
+ end
200
+ end
201
+
202
+ # def test_fotolia_transfer_existing_picture
203
+ # fotolia = Fotolia.new("Fotolia")
204
+ # fotolia.user = @fotolia_user
205
+ # fotolia.password = @fotolia_password
206
+ # photo = Photo.new("/media/LACIE/private/CF-Card/DCIM/119CANON/IMG_3267_zugeschnitten_blank_names.jpg")
207
+ # assert fotolia.transfer(photo)
208
+ # end
209
+
210
+ def test_fotolia_transfer_existing_no_duplicate_picture
211
+ if REAL_TRANSFER
212
+ fotolia = Fotolia.new("Fotolia")
213
+ fotolia.user = @fotolia_user
214
+ fotolia.password = @fotolia_password
215
+ fotolia.ftp_user = @fotolia_ftp_user
216
+ fotolia.ftp_password = @fotolia_ftp_password
217
+ photo = Photo.new("/media/LACIE/private/CF-Card/DCIM/119CANON/IMG_3267_zugeschnitten_blank_names.jpg")
218
+ assert_equal :duplicate, fotolia.transfer(photo)
219
+ end
220
+ end
221
+
222
+ def test_config_params_fotolia
223
+ fotolia = Fotolia.new("Fotolia Site")
224
+ assert fotolia.user
225
+ assert fotolia.password
226
+ assert fotolia.ftp_user
227
+ assert fotolia.ftp_password
228
+ assert_equal @fotolia_user, fotolia.user
229
+ assert_equal @fotolia_password, fotolia.password
230
+ assert_equal @fotolia_ftp_user, fotolia.ftp_user
231
+ assert_equal @fotolia_ftp_password, fotolia.ftp_password
232
+ end
233
+
234
+ def test_config_params_zoonar
235
+ zoonar = Zoonar.new("zoonar Site")
236
+ assert zoonar.user
237
+ assert zoonar.password
238
+ assert_equal @zoonar_user, zoonar.user
239
+ assert_equal @zoonar_password, zoonar.password
240
+ #kein ftp assert_equal @zoonar_ftp_user, zoonar.ftp_user
241
+ #kein ftp assert_equal @zoonar_ftp_password, zoonar.ftp_password
242
+ end
243
+
244
+ def test_config_params_photocase
245
+ photocase = Photocase.new("photocase Site")
246
+ assert photocase.user
247
+ assert photocase.password
248
+ assert_equal @photocase_user, photocase.user
249
+ assert_equal @photocase_password, photocase.password
250
+ #kein ftp assert_equal @photocase_ftp_user, photocase.ftp_user
251
+ #kein ftp assert_equal @photocase_ftp_password, photocase.ftp_password
252
+ end
253
+
254
+ def test_config_params_dreamstime
255
+ dreamstime = Dreamstime.new("Dreamstime Site")
256
+ assert dreamstime.user
257
+ assert dreamstime.password
258
+ assert dreamstime.ftp_user
259
+ assert dreamstime.ftp_password
260
+ assert_equal @dreamstime_user, dreamstime.user
261
+ assert_equal @dreamstime_password, dreamstime.password
262
+ assert_equal @dreamstime_ftp_user, dreamstime.ftp_user
263
+ assert_equal @dreamstime_ftp_password, dreamstime.ftp_password
264
+ end
265
+
266
+ def test_config_params_bigstockphoto
267
+ bigstockphoto = Bigstockphoto.new("Bigstockphoto Site")
268
+ assert bigstockphoto.user
269
+ assert bigstockphoto.password
270
+ assert bigstockphoto.ftp_user
271
+ assert bigstockphoto.ftp_password
272
+ assert_equal @bigstockphoto_user, bigstockphoto.user
273
+ assert_equal @bigstockphoto_password, bigstockphoto.password
274
+ assert_equal @bigstockphoto_ftp_user, bigstockphoto.ftp_user
275
+ assert_equal @bigstockphoto_ftp_password, bigstockphoto.ftp_password
276
+ end
277
+
278
+ def test_config_params_panthermedia
279
+ site = Panthermedia.new("Panthermedia Site")
280
+ #assert site.user
281
+ #assert site.password
282
+ assert site.ftp_user
283
+ assert site.ftp_password
284
+ assert_equal @panthermedia_user, site.user
285
+ assert_equal @panthermedia_password, site.password
286
+ assert_equal @panthermedia_ftp_user, site.ftp_user
287
+ assert_equal @panthermedia_ftp_password, site.ftp_password
288
+ end
289
+
290
+ def test_grep
291
+ file = "test/testgrep.dat"
292
+ content = "zoonar\tIMG1.jpg\n"+
293
+ "fotolia\tIMG1.jpg\n"+
294
+ "zoonar\tIMG2.jpg\n"+
295
+ "fotolia\tIMG2.jpg\n"
296
+ File.open("test/testgrep.dat","w") {|f|
297
+ f.puts content
298
+ }
299
+ assert_equal 1, grep(file,/zoonar\tIMG1.jpg/).size
300
+ assert_equal 1, grep(file,/fotolia\tIMG1.jpg/).size
301
+ assert_equal 1, grep(file,/zoonar\tIMG2.jpg/).size
302
+ assert_equal 1, grep(file,/fotolia\tIMG2.jpg/).size
303
+ assert_equal 0, grep(file,/zoonar\tIMG3.jpg/).size
304
+ assert_equal 0, grep(file,/fotolia\tIMG3.jpg/).size
305
+ end
306
+
307
+ def test_photocase_transfer_1
308
+ after Date.new(2008,6,20) do
309
+ photocase = Photocase.new("Photocase")
310
+ photocase.user = @photocase_user
311
+ photocase.password = @photocase_password
312
+ photo = Photo.new("test/1234.jpg")
313
+ photocase.transfer(photo,true,true)
314
+ if REAL_TRANSFER
315
+ #assert fotolia.transfer(photo)
316
+ #TODO: zwei Gruende, warum das fehlschlagen kann:
317
+ # 1. Datei nicht vorhanden
318
+ # 2. Argument kein Photo-Objekt
319
+ # => bessere Tests
320
+ # assert_raise (RuntimeError) {
321
+ # fotolia.transfer("123.jpg")
322
+ # }
323
+ end
324
+ end # after
325
+ end
326
+
327
+ def test_config_params_pixelio
328
+ after Date.new(2008,7,20)+20 do
329
+ pixelio = Pixelio.new("Pixelio Site")
330
+ assert pixelio.user
331
+ assert pixelio.password
332
+ assert_equal @pixelio_user, pixelio.user
333
+ assert_equal @pixelio_password, pixelio.password
334
+ #kein ftp assert_equal @pixelio_ftp_user, pixelio.ftp_user
335
+ #kein ftp assert_equal @pixelio_ftp_password, pixelio.ftp_password
336
+ end # after
337
+ end
338
+
339
+ def test_dreamstime_object
340
+ # angemeldet.
341
+ dreamstime = Dreamstime.new("Dreamstime Site")
342
+ assert_kind_of Dreamstime, dreamstime
343
+ end
344
+
345
+ def test_bigstockphoto_object
346
+ # http://www.bigstockphoto.com/
347
+ # We accept JPG, EPS, AI, PSD, PDF and PNG file formats.
348
+ # All art or images MUST be created by you alone, no exceptions.
349
+ #Step ONE: Upload your model releases in Release Manager>> if needed... then FTP upload your images - no folders - separate files only. Use this FTP information to log into your BigStockPhoto FTP account:
350
+
351
+ # host: bigstockphoto.com
352
+ # username: your BSP username
353
+ # password: your BSP password
354
+
355
+ #Step TWO: After upload, go to your Uploaded Images Queue to add your keywords, assign releases, titles, descriptions, categories etc. before pushing them to final BigStockPhoto Approval Queue. Also see the new FTP Status Log if needed to check upload status of images.
356
+ bigstockphoto = Bigstockphoto.new("Bigstockphoto Site")
357
+ assert_kind_of Bigstockphoto, bigstockphoto
358
+ end
359
+
360
+ after Date.new(2008,7,25) do
361
+ def test_shutterstock_object
362
+ shutterstock = Shutterstock.new("Shutterstock Site")
363
+ assert_kind_of Shutterstock, shutterstock
364
+ end
365
+ end
366
+
367
+ after Date.new(2008,7,25) do
368
+ def test_istockphoto_object
369
+ # angemeldet, aber man muß noch vorstellungsbilder hochladen
370
+ istockphoto = Istockphoto.new("Istockphoto Site")
371
+ assert_kind_of Istockphoto, istockphoto
372
+ end
373
+ end
374
+
375
+ after Date.new(2008,7,25) do
376
+ def test_stockxpert_object
377
+ # angemeldet, aber man muss noch vorstellungsbilder hochladen
378
+ stockxpert = Stockxpert.new("Stockxpert Site")
379
+ assert_kind_of Stockxpert, stockxpert
380
+ end
381
+ end
382
+
383
+ after Date.new(2008,7,25)+10 do
384
+ def test_Einszweidreirf_object
385
+ einszweidreirf = Einszweidreirf.new("123rf Site")
386
+ assert_kind_of Einszweidreirf, einszweidreirf
387
+ end
388
+ end
389
+
390
+ after Date.new(2008,7,25) do
391
+ def test_Panthermedia_object
392
+ panthermedia = Panthermedia.new("Panthermedia Site")
393
+ assert_kind_of Panthermedia, panthermedia
394
+ end
395
+ #Shutterstock, iStockphoto , StockXpert , Dreamstime , Bigstockphoto , 123rf und Panthermedia finden Sie auf unserer Partnerseite Fotos kaufen.de
396
+ end
397
+
398
+
399
+
400
+ def test_max_errors
401
+ site = Fotolia.new('fotolia')
402
+ assert_equal 3, site.max_errors
403
+ site = Zoonar.new('zoonar')
404
+ assert_equal 3, site.max_errors
405
+ site = Photocase.new('photocase')
406
+ assert_equal 3, site.max_errors
407
+ site = Dreamstime.new('dreamstime')
408
+ assert_equal 3, site.max_errors
409
+ site = Panthermedia.new('pantermedia')
410
+ assert_equal 3, site.max_errors
411
+ end
412
+
413
+ def test_set_max_errors
414
+ site = Fotolia.new('fotolia')
415
+ site.max_errors = 4
416
+ assert_equal 4, site.max_errors
417
+
418
+ site = Zoonar.new('zoonar')
419
+ site.max_errors = 5
420
+ assert_equal 5, site.max_errors
421
+
422
+ site = Photocase.new('photocase')
423
+ site.max_errors = 6
424
+ assert_equal 6, site.max_errors
425
+ end
426
+
427
+ def test_iptc_keywords
428
+ after Date.new(2008,7,21)+10 do
429
+ expected = ['Berlin','gwb','Blume','Biene','Verkehr','S-Bahn']
430
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
431
+ photo.set_keywords
432
+ assert_equal expected, photo.keywords
433
+ end
434
+ end
435
+
436
+ def test_iptc_file_keywords
437
+ after Date.new(2008,7,21)+10 do
438
+ expected = 'Berlin,gwb,Blume,Biene,Verkehr,S-Bahn'
439
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
440
+ photo.set_keywords
441
+ assert_equal expected, photo.file_keywords
442
+ end
443
+ end
444
+
445
+ def test_iptc_title
446
+ after Date.new(2008,7,21)+10 do
447
+ expected = 'meine Katze'
448
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
449
+ photo.set_keywords
450
+ assert_equal expected, photo.title
451
+ end
452
+ end
453
+
454
+ def test_iptc_file_title
455
+ after Date.new(2008,7,1)+30 do
456
+ expected = 'meine Katze'
457
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
458
+ photo.set_keywords
459
+ assert_equal expected, photo.file_title
460
+ end
461
+ end
462
+
463
+ def test_string_to_keyword_array
464
+ s = "Berlin"
465
+ assert_equal ['Berlin'], Photo.to_tags(s)
466
+ s = "Berlin,Graffiti"
467
+ assert_equal ['Berlin','Graffiti'], Photo.to_tags(s)
468
+ s = "Berlin Graffiti"
469
+ assert_equal ['Berlin','Graffiti'], Photo.to_tags(s)
470
+ s = "Berlin Graffiti,Test"
471
+ assert_equal ['Berlin','Graffiti','Test'], Photo.to_tags(s)
472
+ s = "Berlin Graffiti, Test"
473
+ assert_equal ['Berlin','Graffiti','Test'], Photo.to_tags(s)
474
+ s = "Berlin Graffiti, Test\n zweite, dritte"
475
+ assert_equal ['Berlin','Graffiti','Test','zweite','dritte'], Photo.to_tags(s)
476
+ s = "Berlin Graffiti, Test\n zweite\tdritte"
477
+ assert_equal ['Berlin','Graffiti','Test','zweite','dritte'], Photo.to_tags(s)
478
+ s = "Berlin Graffiti, Test\n zweite|dritte"
479
+ assert_equal ['Berlin','Graffiti','Test','zweite','dritte'], Photo.to_tags(s)
480
+ end
481
+
482
+ def test_iptc_file_keywords_non_existing_tag_file
483
+ expected = 'Berlin gwb Blume Biene'
484
+ photo = Photo.new(File.join('test','IMG_9999.JPG'))
485
+
486
+ photo.set_keywords
487
+ assert_equal expected, photo.file_keywords
488
+ end
489
+
490
+ def test_total_per_day_from_config_file
491
+ zoonar = Zoonar.new('zoonar')
492
+ assert_equal 10, zoonar.total_per_day
493
+ fotolia = Fotolia.new('fotolia')
494
+ assert_equal 11, fotolia.total_per_day
495
+ photocase = Photocase.new('photocase')
496
+ assert_equal 12, photocase.total_per_day
497
+
498
+ assert_equal 0, zoonar.sent_today
499
+ assert_equal 0, fotolia.sent_today
500
+ assert_equal 0, photocase.sent_today
501
+ end
502
+ #end
503
+
504
+ #class Multistockphoto
505
+ after Date.new(2008,7,30) do
506
+
507
+ def config_params_pixelio(*args)
508
+ raise NotImplementedError, 'Need to write config_params_pixelio'
509
+ end
510
+
511
+ def config_params_zoonar(*args)
512
+ raise NotImplementedError, 'Need to write config_params_zoonar'
513
+ end
514
+
515
+ def fotolia(*args)
516
+ raise NotImplementedError, 'Need to write fotolia'
517
+ end
518
+
519
+
520
+ def fotolia_transfer_existing_no_duplicate_picture(*args)
521
+ raise NotImplementedError, 'Need to write fotolia_transfer_existing_no_duplicate_picture'
522
+ end
523
+
524
+ def iptc_file_keywords(*args)
525
+ raise NotImplementedError, 'Need to write iptc_file_keywords'
526
+ end
527
+
528
+ def iptc_file_keywords_non_existing_tag_file(*args)
529
+ raise NotImplementedError, 'Need to write iptc_file_keywords_non_existing_tag_file'
530
+ end
531
+
532
+ def iptc_keywords(*args)
533
+ raise NotImplementedError, 'Need to write iptc_keywords'
534
+ end
535
+
536
+ def max_errors(*args)
537
+ raise NotImplementedError, 'Need to write max_errors'
538
+ end
539
+
540
+ def multistockphoto_group(*args)
541
+ raise NotImplementedError, 'Need to write multistockphoto_group'
542
+ end
543
+
544
+ def photo(*args)
545
+ raise NotImplementedError, 'Need to write photo'
546
+ end
547
+
548
+ def photocase_transfer_1(*args)
549
+ raise NotImplementedError, 'Need to write photocase_transfer_1'
550
+ end
551
+
552
+ def set_max_errors(*args)
553
+ raise NotImplementedError, 'Need to write set_max_errors'
554
+ end
555
+
556
+ # def setup(*args)
557
+ # raise NotImplementedError, 'Need to write setup'
558
+ # end
559
+
560
+ def test_heute_schon_gesendet
561
+ after Date.new(2008,7,27) do
562
+ raise NotImplementedError, 'Need to write test_heute_schon_gesendet'
563
+ end
564
+ end
565
+
566
+ end
567
+
568
+ def test_password
569
+ password = rand(1_000_000).to_s
570
+ site = Fotolia.new('fotolia')
571
+ site.password = password
572
+ assert_equal password, site.password
573
+
574
+ password = rand(1_000_000).to_s
575
+ site = Zoonar.new('zoonar')
576
+ site.password = password
577
+ assert_equal password, site.password
578
+
579
+ password = rand(1_000_000).to_s
580
+ site = Photocase.new('photocase')
581
+ site.password = password
582
+ assert_equal password, site.password
583
+
584
+ password = rand(1_000_000).to_s
585
+ site = Dreamstime.new('dreamstime')
586
+ site.password = password
587
+ assert_equal password, site.password
588
+
589
+ password = rand(1_000_000).to_s
590
+ site = Bigstockphoto.new('bigstockphoto')
591
+ site.password = password
592
+ assert_equal password, site.password
593
+
594
+ password = rand(1_000_000).to_s
595
+ site = Panthermedia.new('panthermedia')
596
+ site.password = password
597
+ assert_equal password, site.password
598
+ end
599
+
600
+ def test_password_equals
601
+ password = rand(1_000_000).to_s
602
+ site = Fotolia.new('fotolia')
603
+ site.password = password
604
+ assert_equal password, site.password
605
+
606
+ password = rand(1_000_000).to_s
607
+ site = Zoonar.new('zoonar')
608
+ site.password = password
609
+ assert_equal password, site.password
610
+
611
+ password = rand(1_000_000).to_s
612
+ site = Photocase.new('photocase')
613
+ site.password = password
614
+ assert_equal password, site.password
615
+
616
+ password = rand(1_000_000).to_s
617
+ site = Dreamstime.new('dreamstime')
618
+ site.password = password
619
+ assert_equal password, site.password
620
+
621
+ password = rand(1_000_000).to_s
622
+ site = Bigstockphoto.new('dreamstime')
623
+ site.password = password
624
+ assert_equal password, site.password
625
+
626
+ password = rand(1_000_000).to_s
627
+ site = Panthermedia.new('panthermedia')
628
+ site.password = password
629
+ assert_equal password, site.password
630
+ end
631
+
632
+ after Date.new(2008,7,25)+10do
633
+ def test_photos_fuer_heute_uebrig_eh
634
+ raise NotImplementedError, 'Need to write test_photos_fuer_heute_uebrig_eh'
635
+ end
636
+ end
637
+
638
+ def test_zoonar_nur_noch_5_uploads_moeglich
639
+ site = Mock_Zoonar.new('zoonar',:remaining => 5)
640
+ photo = Photo.new("test/1234.jpg")
641
+ assert site.transfer(photo)
642
+ assert site.transfer(photo)
643
+ assert site.transfer(photo)
644
+ assert site.transfer(photo)
645
+ assert site.transfer(photo)
646
+ assert_raise(UploadException) {
647
+ site.transfer(photo)
648
+ }
649
+ assert_raise(UploadException) {
650
+ site.transfer(photo)
651
+ }
652
+ end
653
+
654
+
655
+ def test_bin_simple
656
+ after Date.new(2008,7,25)+10 do
657
+ begin
658
+ Dir.mkdir 'upload'
659
+ rescue Errno::EEXIST
660
+ #ignore
661
+ end
662
+ ###leere sendeliste erzeugen
663
+ File.unlink SENDLIST
664
+ File.open(SENDLIST, "w") {}
665
+ FileUtils.cp("IMG_0000.JPG", "upload/1.gif")
666
+ FileUtils.cp("IMG_0000.JPG", "upload/2.gif")
667
+ FileUtils.cp("IMG_0000.JPG", "upload/3.gif")
668
+ expected="sending all unsent photos
669
+ fotolia:upload/1.gif ... OK
670
+ zoonar:upload/1.gif ... OK
671
+ photocase:upload/1.gif ... OK
672
+ fotolia:upload/2.gif ... OK
673
+ zoonar:upload/2.gif ... OK
674
+ photocase:upload/2.gif ... OK
675
+ fotolia:upload/3.gif ... OK
676
+ zoonar:upload/3.gif ... OK
677
+ photocase:upload/3.gif ... OK
678
+ 9 photos sent.\n"
679
+ result = `#{BIN}multistockphoto --send-all --dont-send --dont-log`
680
+ assert_equal expected, result
681
+ end
682
+ end
683
+
684
+ def test_bin_simple_verbose
685
+ after Date.new(2008,7,26)+10 do
686
+ begin
687
+ Dir.mkdir 'upload'
688
+ rescue Errno::EEXIST
689
+ #ignore
690
+ end
691
+ ###leere sendeliste erzeugen
692
+ File.unlink SENDLIST
693
+ File.open(SENDLIST, "w") {}
694
+ FileUtils.cp("IMG_0000.JPG", "upload/1.gif")
695
+ FileUtils.cp("IMG_0000.JPG", "upload/2.gif")
696
+ FileUtils.cp("IMG_0000.JPG", "upload/3.gif")
697
+ expected="sending all unsent photos
698
+ fotolia:upload/1.gif ... OK
699
+ 1:23
700
+ {:fotolia=>1, :photocase=>0, :zoonar=>0}
701
+ zoonar:upload/1.gif ... OK
702
+ 1:23
703
+ {:photocase=>0, :fotolia=>1, :zoonar=>1}
704
+ photocase:upload/1.gif ... OK
705
+ 1:23
706
+ {:photocase=>1, :fotolia=>1, :zoonar=>1}
707
+ fotolia:upload/2.gif ... OK
708
+ 1:23
709
+ {:fotolia=>2, :zoonar=>1, :photocase=>1}
710
+ zoonar:upload/2.gif ... OK
711
+ 1:23
712
+ {:fotolia=>2, :zoonar=>2, :photocase=>1}
713
+ photocase:upload/2.gif ... OK
714
+ 1:23
715
+ {:fotolia=>2, :zoonar=>2, :photocase=>2}
716
+ fotolia:upload/3.gif ... OK
717
+ 1:23
718
+ {:fotolia=>3, :zoonar=>2, :photocase=>2}
719
+ zoonar:upload/3.gif ... OK
720
+ 1:23
721
+ {:fotolia=>3, :zoonar=>3, :photocase=>2}
722
+ photocase:upload/3.gif ... OK
723
+ 1:23
724
+ {:fotolia=>3, :zoonar=>3, :photocase=>3}
725
+ 9 photos sent.\n"
726
+ result = `#{BIN}multistockphoto --send-all --verbose --dont-send --dont-log`
727
+ assert_equal expected, result
728
+ end
729
+ end
730
+
731
+
732
+ def test_bin_no_tags
733
+ expected = "upload/1.gif\nupload/3.gif\n"
734
+
735
+ result = `#{BIN}multistockphoto --no-tags`
736
+ assert_equal expected, result
737
+
738
+ result = `#{BIN}multistockphoto -q`
739
+ assert_equal expected, result
740
+ end
741
+
742
+ def test_sender
743
+ sender = Sender.new("Thomas Preymesser")
744
+ assert_kind_of Sender, sender
745
+ end
746
+
747
+ def test_active_sites
748
+ sender = Sender.new("Thomas")
749
+ assert_equal [:fotolia, :zoonar, :photocase, :dreamstime, :bigstockphoto,
750
+ :panthermedia],
751
+ sender.active_sites
752
+ end
753
+
754
+ def test_upload_dir
755
+ sender = Sender.new("Thomas")
756
+ assert_equal 'upload', sender.upload_dir
757
+ end
758
+
759
+ def test_done_dir
760
+ sender = Sender.new("Thomas")
761
+ assert_equal 'done', sender.done_dir
762
+ end
763
+
764
+ def test_bin_nothing_raised_send_all
765
+ assert_nothing_raised() {
766
+ puts `#{BIN}multistockphoto --send-all --dont-send --dont-log`
767
+ }
768
+ assert_nothing_raised() {
769
+ puts `#{BIN}multistockphoto --send-all --verbose --dont-send --dont-log`
770
+ }
771
+ end
772
+
773
+ def test_list_done
774
+ result = `#{BIN}multistockphoto --list-done`
775
+ ret = $?
776
+ #p result
777
+ assert ret.exited?
778
+ assert_equal 0, ret.exitstatus
779
+ end
780
+
781
+ def test_purge_done
782
+ result = `#{BIN}multistockphoto --purge-done`
783
+ ret = $?
784
+ #p result
785
+ assert ret.exited?
786
+ assert_equal 0, ret.exitstatus
787
+ end
788
+
789
+ def test_not_sent
790
+ result = `#{BIN}multistockphoto --not-sent`
791
+ ret = $?
792
+ #p result
793
+ assert ret.exited?
794
+ assert_equal 0, ret.exitstatus
795
+ end
796
+
797
+ def test_can_handle_orientation
798
+ assert ! Fotolia.can_handle_orientation?
799
+ assert ! Zoonar.can_handle_orientation?
800
+ assert ! Photocase.can_handle_orientation?
801
+ assert ! Panthermedia.can_handle_orientation?
802
+ end
803
+
804
+ def test_specific_file_sent_to_site
805
+ after Date.new(2008,7,21)+10 do
806
+ sender = Sender.new('icke')
807
+ assert sender.sent_to?("upload/IMG_3333.JPG", :fotolia)
808
+ assert ! sender.sent_to?("upload/IMG_9999.JPG", :fotolia)
809
+ end
810
+ end
811
+
812
+ def test_accepted_fileformats
813
+ #site = Bigstockphoto.new("bigstockphoto")
814
+ #We accept JPG, EPS, AI, PSD, PDF and PNG file formats.
815
+ assert Bigstockphoto.accept?("JPG")
816
+ assert Bigstockphoto.accept?("JPEG")
817
+ assert Bigstockphoto.accept?("EPS")
818
+ assert Bigstockphoto.accept?("AI")
819
+ assert Bigstockphoto.accept?("PSD")
820
+ assert Bigstockphoto.accept?("PDF")
821
+ assert Bigstockphoto.accept?("PNG")
822
+ assert ! Bigstockphoto.accept?("lalala")
823
+
824
+ assert Bigstockphoto.accept?(".JPG")
825
+ assert Bigstockphoto.accept?(".JPEG")
826
+ assert Bigstockphoto.accept?(".EPS")
827
+ assert Bigstockphoto.accept?(".AI")
828
+ assert Bigstockphoto.accept?(".PSD")
829
+ assert Bigstockphoto.accept?(".PDF")
830
+ assert Bigstockphoto.accept?(".PNG")
831
+ assert ! Bigstockphoto.accept?(".lalala")
832
+
833
+ assert Bigstockphoto.accept?("jpg")
834
+ assert Bigstockphoto.accept?("Jpeg")
835
+ assert Bigstockphoto.accept?("eps")
836
+ assert Bigstockphoto.accept?("ai")
837
+ assert Bigstockphoto.accept?("psd")
838
+ assert Bigstockphoto.accept?("pdf")
839
+ assert Bigstockphoto.accept?("Png")
840
+ assert ! Bigstockphoto.accept?("Lalala")
841
+
842
+
843
+ assert Fotolia.accept?('jpg')
844
+ assert Fotolia.accept?('jpeg')
845
+ assert Fotolia.accept?('svg')
846
+ assert ! Fotolia.accept?('psd')
847
+
848
+
849
+
850
+ end
851
+
852
+ def test_translated_iptc_file_keywords
853
+ after Date.new(2008,7,31) do
854
+ expected = 'Berlin,gwb,flower,bee,traffic'
855
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
856
+ photo.set_keywords(:de,:en)
857
+ assert_equal expected, photo.file_keywords
858
+ end
859
+ end
860
+
861
+ def test_photosize_valid?
862
+ photo = Photo.new(File.join('test','IMG_3602.JPG'))
863
+ ALLSITES.each {|site_name|
864
+ site = eval(site_name.to_s.capitalize+".new(#{site_name.to_s.capitalize})")
865
+ assert site.photosize_valid?(photo)
866
+ }
867
+ end
868
+
869
+ def test_shutterstock_object
870
+ after Date.new(2008,7,25)+10 do
871
+ site = Shutterstock.new('Shutterstock')
872
+ assert_kind_of Shutterstock, site
873
+ end
874
+ end
875
+ def test_istockphoto_object
876
+ after Date.new(2008,7,25)+10 do
877
+ site = Istockphoto.new('iStockphoto')
878
+ assert_kind_of Istockphoto, site
879
+ end
880
+ end
881
+ def test_stockxpert_object
882
+ after Date.new(2008,7,25)+10 do
883
+ site = Stockxpert.new('StockXpert')
884
+ assert_kind_of Stockxpert, site
885
+ end
886
+ end
887
+ def test_123rf_object
888
+ after Date.new(2008,7,25)+10 do
889
+ site = Einszweidreirf.new('123rf')
890
+ assert_kind_of Einszweidreirf, site
891
+ end
892
+ end
893
+
894
+ def test_panthermedia_object
895
+ site = Panthermedia.new('Panthermedia')
896
+ assert_kind_of Panthermedia, site
897
+ end
898
+
899
+ def test_fineartprint
900
+ flunk "http://www.fineartprint.de noch implementieren"
901
+ end
902
+
903
+ end # after
904
+
905
+ end
906
+