0
@@ -7,7 +7,7 @@ class TestFlickr < Test::Unit::TestCase
0
def test_should_instantiate_new_flickr_client
0
Flickr.any_instance.stubs(:login)
0
flickr = Flickr.new('some_api_key', 'email@test.com', 'some_password', 'some_shared_secret')
0
@@ -34,7 +34,7 @@ class TestFlickr < Test::Unit::TestCase
0
flickr = Flickr.new('api_key' => 'some_api_key', 'email' => 'email@test.com', 'password' => 'some_password', 'shared_secret' => 'some_shared_secret', 'foo' => 'bar')
0
- # signature_from
tests
0
+ # signature_from
method tests
0
def test_should_return_signature_from_given_params
0
assert_equal Digest::MD5.hexdigest('shared_secret_codea_param1234xb_param5678yc_param97531t'),
0
authenticated_flickr_client.send(:signature_from, {:b_param => '5678y', 'c_param' => '97531t', :a_param => '1234x', :d_param => nil})
0
@@ -44,7 +44,7 @@ class TestFlickr < Test::Unit::TestCase
0
assert_nil flickr_client.send(:signature_from, {:b_param => '5678y', :c_param => '97531t', :a_param => '1234x'})
0
+ # request_url
method tests
0
def test_should_get_signature_for_params_when_building_url
0
f = authenticated_flickr_client
0
f.expects(:signature_from).with( 'method' => 'flickr.someMethod',
0
@@ -86,7 +86,7 @@ class TestFlickr < Test::Unit::TestCase
0
f.some_unknown_methodForFlickr
0
+ # request
method tests
0
def test_should_make_successful_request
0
f.expects(:http_get).with('some.url').returns(successful_xml_response)
0
@@ -162,7 +162,7 @@ class TestFlickr < Test::Unit::TestCase
0
assert_equal f, user.client
0
def test_should_get_recent_photos_if_no_params_for_photos
0
f.expects(:photos_getRecent).returns({"photos" => {"photo" => []}})
0
@@ -180,7 +180,7 @@ class TestFlickr < Test::Unit::TestCase
0
+ # photos_search
method tests
0
def test_should_search_photos
0
f = authenticated_flickr_client
0
f.expects(:request).with('photos.search', anything).returns(dummy_photos_response)
0
@@ -188,7 +188,7 @@ class TestFlickr < Test::Unit::TestCase
0
assert_kind_of Flickr::Photo, photos.first
0
def test_should_find_user_from_email
0
f.expects(:request).with('people.findByEmail', anything).returns(dummy_user_response)
0
@@ -211,6 +211,30 @@ class TestFlickr < Test::Unit::TestCase
0
assert_equal f, user.client
0
+ def test_should_search_for_given_group
0
+ f.expects(:request).with("groups.search", {"text" => "foo"}).returns(dummy_groups_response)
0
+ def test_should_search_for_given_group_with_additional_params
0
+ f.expects(:request).with("groups.search", {"text" => "foo", "per_page" => "1"}).returns(dummy_groups_response)
0
+ f.groups("foo", "per_page" => "1")
0
+ def test_should_instantiate_groups_from_search_response
0
+ f.stubs(:request).returns(dummy_groups_response)
0
+ assert_kind_of Array, groups = f.groups("foo")
0
+ assert_kind_of Flickr::Group, group = groups.first
0
+ assert_equal "group1", group.id
0
+ assert_equal "Group One", group.name
0
+ assert_equal "0", group.instance_variable_get(:@eighteenplus)
0
+ assert_equal f, group.client
0
@@ -232,15 +256,6 @@ class TestFlickr < Test::Unit::TestCase
0
# assert_equal @user_id, @f.find_by_url(@user_url).getInfo.id # find user by URL
0
- # assert_equal 100, @f.photos.size # find recent
0
- # assert_equal @user_id, @f.photos('user_id'=>@user_id).first.getInfo.owner.id # search by user_id
0
- # assert_kind_of Flickr::Group, @f.groups.first # find all active groups
0
# assert_kind_of Array, @f.licenses # find all licenses
0
@@ -251,7 +266,7 @@ class TestFlickr < Test::Unit::TestCase
0
+ # #####
Flickr::User tests0
def test_should_instantiate_user
0
user = Flickr::User.new({ 'id' => 'foo123',
0
@@ -414,9 +429,9 @@ class TestFlickr < Test::Unit::TestCase
0
+ #
##### Flickr::Photo tests0
- def test_should_
store_initialize_from_id
0
+ def test_should_
initialize_photo_from_id
0
photo = Flickr::Photo.new("foo123")
0
assert_equal "foo123", photo.id
0
@@ -599,6 +614,56 @@ class TestFlickr < Test::Unit::TestCase
0
+ # ##### Flickr::Group tests
0
+ def test_should_instantiate_group_from_id
0
+ group = Flickr::Group.new("group1")
0
+ assert_equal "group1", group.id
0
+ # tests old api for instantiating groups
0
+ def test_should_instantiate_group_from_id_and_api_key
0
+ Flickr.expects(:new).with("some_api_key").returns(f)
0
+ group = Flickr::Group.new("group1", "some_api_key")
0
+ assert_equal f, group.client
0
+ # new api for instantiating groups
0
+ def test_should_instantiate_group_from_params_hash
0
+ group = Flickr::Group.new("id" => "group1", "name" => "Group One", "foo" => "bar")
0
+ assert_equal "group1", group.id
0
+ assert_equal "Group One", group.name
0
+ assert_equal "bar", group.instance_variable_get(:@foo)
0
+ def test_should_use_flickr_client_passed_in_params_hash_when_instantiating_group
0
+ Flickr.expects(:new).never
0
+ group = Flickr::Group.new("id" => "group1", "name" => "Group One", "client" => f)
0
+ assert_equal f, group.client
0
+ # def test_should_initialize_photo_from_id
0
+ # photo = Flickr::Photo.new("foo123")
0
+ # assert_equal "foo123", photo.id
0
+ # def test_should_save_extra_params_as_instance_variables
0
+ # photo = Flickr::Photo.new('foo123', 'some_api_key', { 'key1' => 'value1', 'key2' => 'value2'})
0
+ # assert_equal 'value1', photo.instance_variable_get(:@key1)
0
+ # assert_equal 'value2', photo.instance_variable_get(:@key2)
0
+ # def test_should_be_able_to_access_instance_variables_through_hash_like_interface
0
+ # photo = Flickr::Photo.new
0
+ # photo.instance_variable_set(:@key1, 'value1')
0
+ # assert_equal 'value1', photo['key1']
0
+ # assert_equal 'value1', photo[:key1]
0
+ # assert_nil photo[:key2]
0
+ # assert_nil photo['key2']
0
@@ -674,15 +739,15 @@ class TestFlickr < Test::Unit::TestCase
0
-
"key3" => "value3"}] } }
0
+
"key3" => "value3"}] } }
0
def dummy_single_photo_response
0
- "key2" => "value2" } } }
0
+ "key2" => "value2" } } }
0
def dummy_user_response
0
@@ -692,6 +757,17 @@ class TestFlickr < Test::Unit::TestCase
0
+ def dummy_groups_response
0
+ [{ "nsid" => "group1",
0
+ "name" => "Group One",
0
+ "eighteenplus" => "0" },
0
+ "name" => "Group Two",
0
+ "eighteenplus" => "1"}] } }
0
def successful_xml_response
0
<?xml version="1.0" encoding="utf-8" ?>
Comments
No one has commented yet.