<s> import urlparse <EOL> from nose . tools import * <EOL> from tests . base import ApiTestCase <EOL> from tests . factories import AuthUserFactory <EOL> from api . base . settings . defaults import API_BASE <EOL> class TestUsers ( ApiTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestUsers , self ) . setUp ( ) <EOL> self . user_one = AuthUserFactory ( ) <EOL> self . user_two = AuthUserFactory ( ) <EOL> def tearDown ( self ) : <EOL> super ( TestUsers , self ) . tearDown ( ) <EOL> def test_returns_200 ( self ) : <EOL> res = self . app . get ( '<STR_LIT>' . format ( API_BASE ) ) <EOL> assert_equal ( res . status_code , <NUM_LIT:200> ) <EOL> assert_equal ( res . content_type , '<STR_LIT>' ) <EOL> def test_find_user_in_users ( self ) : <EOL> url = "<STR_LIT>" . format ( API_BASE ) <EOL> res = self . app . get ( url ) <EOL> user_son = res . json [ '<STR_LIT:data>' ] <EOL> ids = [ each [ '<STR_LIT:id>' ] for each in user_son ] <EOL> assert_in ( self . user_two . _id , ids ) <EOL> def test_all_users_in_users ( self ) : <EOL> url = "<STR_LIT>" . format ( API_BASE ) <EOL> res = self . app . get ( url ) <EOL> user_son = res . json [ '<STR_LIT:data>' ] <EOL> ids = [ each [ '<STR_LIT:id>' ] for each in user_son ] <EOL> assert_in ( self . user_one . _id , ids ) <EOL> assert_in ( self . user_two . _id , ids ) <EOL> def test_find_multiple_in_users ( self ) : <EOL> url = "<STR_LIT>" . format ( API_BASE ) <EOL> res = self . app . get ( url ) <EOL> user_json = res . json [ '<STR_LIT:data>' ] <EOL> ids = [ each [ '<STR_LIT:id>' ] for each in user_json ] <EOL> assert_in ( self . user_one . _id , ids ) <EOL> assert_in ( self . user_two . _id , ids ) <EOL> def test_find_single_user_in_users ( self ) : <EOL> url = "<STR_LIT>" . format ( API_BASE ) <EOL> self . user_one . fullname = '<STR_LIT>' <EOL> self . user_one . save ( ) <EOL> res = self . app . get ( url ) <EOL> user_json = res . json [ '<STR_LIT:data>' ] <EOL> ids = [ each [ '<STR_LIT:id>' ] for each in user_json ] <EOL> assert_in ( self . user_one . _id , ids ) <EOL> assert_not_in ( self . user_two . _id , ids ) <EOL> def test_find_no_user_in_users ( self ) : <EOL> url = "<STR_LIT>" . format ( API_BASE ) <EOL> res = self . app . get ( url ) <EOL> user_json = res . json [ '<STR_LIT:data>' ] <EOL> ids = [ each [ '<STR_LIT:id>' ] for each in user_json ] <EOL> assert_not_in ( self . user_one . _id , ids ) <EOL> assert_not_in ( self . user_two . _id , ids ) <EOL> def test_users_list_takes_profile_image_size_param ( self ) : <EOL> size = <NUM_LIT> <EOL> url = "<STR_LIT>" . format ( API_BASE , size ) <EOL> res = self . app . get ( url ) <EOL> user_json = res . json [ '<STR_LIT:data>' ] <EOL> for user in user_json : <EOL> profile_image_url = user [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> query_dict = urlparse . parse_qs ( urlparse . urlparse ( profile_image_url ) . query ) <EOL> assert_equal ( int ( query_dict . get ( '<STR_LIT:s>' ) [ <NUM_LIT:0> ] ) , size ) </s>
