0
@@ -188,6 +188,29 @@ 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
+ assert_kind_of Flickr::User, user = f.users("email@test.com")
0
+ assert_equal "12037949632@N01", user.id
0
+ assert_equal "Stewart", user.username
0
+ def test_should_find_user_from_username_if_fails_to_get_from_email
0
+ f.expects(:request).with('people.findByEmail', anything).raises
0
+ f.expects(:request).with('people.findByUsername', anything).returns(dummy_user_response)
0
+ assert_kind_of Flickr::User, f.users("email@test.com")
0
+ def test_should_pass_on_flickr_client_when_finding_user
0
+ f.stubs(:request).returns(dummy_user_response)
0
+ user = f.users("email@test.com")
0
+ assert_equal f, user.client
0
@@ -200,14 +223,6 @@ class TestFlickr < Test::Unit::TestCase
0
- # assert_equal @f.request('test.echo')['stat'], 'ok'
0
- # def test_request_url
0
- # assert_equal "http://flickr.com/services/rest/?api_key=#{@api_key}&method=flickr.test.echo&foo=bar&email=#{@email}&password=#{@password}", @f.request_url('test.echo', ['foo'=>'bar'])
0
# assert_equal @username, @f.user.getInfo.username
0
@@ -222,12 +237,6 @@ class TestFlickr < Test::Unit::TestCase
0
# assert_equal @user_id, @f.photos('user_id'=>@user_id).first.getInfo.owner.id # search by user_id
0
- # assert_equal @username, @f.users(@email).getInfo.username # find by email
0
- # assert_equal @username, @f.users(@username).getInfo.username # find by username
0
- # assert_kind_of Flickr::User, @f.users.first # find all online users
0
# assert_kind_of Flickr::Group, @f.groups.first # find all active groups
0
@@ -240,6 +249,8 @@ class TestFlickr < Test::Unit::TestCase
0
def test_should_instantiate_user
0
@@ -267,17 +278,26 @@ class TestFlickr < Test::Unit::TestCase
0
assert_equal 'bar456', user.client.api_key
0
- def test_should_instantiate_new_client_when_instantiating_user
0
+ def test_should_instantiate_new_client_when_instantiating_user_if_no_client_passed_in_params
0
+ Flickr.expects(:new).returns(f)
0
user = Flickr::User.new({ 'id' => 'foo123',
0
'username' => 'some_user',
0
'auth_token' => 'foobar789',
0
'shared_secret' => 'some_secret',
0
'api_key' => 'an_api_key' })
0
- assert_kind_of Flickr, user.client
0
- assert_equal 'foobar789', user.client.auth_token
0
- assert_equal 'an_api_key', user.client.api_key
0
- assert_equal 'some_secret', user.client.instance_variable_get(:@shared_secret)
0
+ assert_equal f, user.client
0
+ def test_should_not_instantiate_new_client_when_instantiating_user_if_client_passed_in_params
0
+ Flickr.expects(:new).never
0
+ user = Flickr::User.new({ 'id' => 'foo123',
0
+ 'username' => 'some_user',
0
+ 'name' => 'Some User',
0
+ assert_equal f, user.client
0
def test_should_not_instantiate_new_client_if_existing_client_passed
0
@@ -665,6 +685,13 @@ class TestFlickr < Test::Unit::TestCase
0
"key2" => "value2" } } }
0
+ def dummy_user_response
0
+ { "nsid" => "12037949632@N01",
0
+ "username" => "Stewart" }
0
def successful_xml_response
0
<?xml version="1.0" encoding="utf-8" ?>
Comments
No one has commented yet.