flickr 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_request.rb DELETED
@@ -1,36 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- lib = File.dirname(__FILE__)
4
- $:.unshift lib unless $:.include?(lib)
5
-
6
- require 'test/unit'
7
-
8
- class TestRequest < Test::Unit::TestCase
9
-
10
- def setup
11
- @flickr = ::Flickr.new
12
- end
13
-
14
- def test_flickr_api_is_accessible_via_methods
15
- Flickr.new.send :build_classes, ['flickr.fully.legal']
16
-
17
- assert_equal true, @flickr.methods.include?(:fully)
18
- assert_equal true, @flickr.fully.methods.include?(:legal)
19
- end
20
-
21
- def test_invalid_endpoint_definition
22
- e = assert_raises(RuntimeError) do
23
- Flickr.new.send :build_classes, ['not_flickr.something.method']
24
- end
25
- assert_equal "Invalid namespace", e.message
26
- end
27
-
28
- def test_invalid_keys_are_skipped
29
- assert_nothing_raised {
30
- Flickr.new.send :build_classes, ["flickr.hacked; end; raise 'Pwned'; def x"]
31
- }
32
-
33
- assert_equal false, @flickr.methods.include?(:hacked)
34
- end
35
-
36
- end
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- lib = File.dirname(__FILE__)
4
- $:.unshift lib unless $:.include?(lib)
5
-
6
- require 'test/unit'
7
-
8
- class TestResponse < Test::Unit::TestCase
9
-
10
- def test_response_keys_are_turned_into_methods
11
- subject = Flickr::Response.new({ 'le_gal' => 'ok', }, nil)
12
-
13
- assert_equal true, subject.methods.include?(:le_gal)
14
- assert_equal 'ok', subject.le_gal
15
- end
16
-
17
- def test_invalid_keys_are_skipped
18
- response_hash = {
19
- 'illegal; end; raise "Pwned"; def x' => 'skipped'
20
- }
21
-
22
- assert_nothing_raised {
23
- Flickr::Response.new(response_hash, nil)
24
- }
25
-
26
- subject = Flickr::Response.new(response_hash, nil)
27
- assert_equal false, subject.methods.include?(:illegal)
28
- end
29
-
30
- end
data/test/test_upload.rb DELETED
@@ -1,41 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- lib = File.dirname(__FILE__)
4
- $:.unshift lib unless $:.include?(lib)
5
-
6
- require 'test/unit'
7
-
8
- class TestUpload < Test::Unit::TestCase
9
-
10
- def setup
11
- @flickr = ::Flickr.new
12
-
13
- @flickr.access_token = ENV['FLICKR_ACCESS_TOKEN']
14
- @flickr.access_secret = ENV['FLICKR_ACCESS_SECRET']
15
- end
16
-
17
- def test_upload
18
- u = info = nil
19
- path = File.dirname(__FILE__) + '/image testée.jpg'
20
- title = "Titre de l'image testée"
21
- description = "Ceci est la description de l'image testée"
22
-
23
- assert File.exist? path
24
-
25
- assert_nothing_raised do
26
- u = @flickr.upload_photo path,
27
- :title => title,
28
- :description => description
29
- end
30
-
31
- assert_nothing_raised do
32
- info = @flickr.photos.getInfo :photo_id => u.to_s
33
- end
34
-
35
- assert_equal title, info.title
36
- assert_equal description, info.description
37
-
38
- assert_nothing_raised {@flickr.photos.delete :photo_id => u.to_s}
39
- end
40
-
41
- end