def sample_get_users(): url = os.environ.get('FLN_URL') oauth_token = os.environ.get('FLN_OAUTH_TOKEN') session = Session(oauth_token=oauth_token, url=url) query = create_get_users_object( user_ids=[ 110013, 221202, 231203, ], user_details=create_get_users_details_object( basic=True, profile_description=True, reputation=True, ), ) try: p = get_users(session, query) except UsersNotFoundException as e: print(('Error message: {}'.format(e.message))) print(('Server response: {}'.format(e.error_code))) return None else: return p
def test_create_get_users_object(self): query = create_get_users_object( user_ids=[ 201, 202, 203, ], ) self.assertIn(('users[]', [201, 202, 203]), query.items())
def test_get_users(self): user_get_data = {'user_ids': [100, 200]} query = create_get_users_object(user_ids=user_get_data['user_ids']) self.session.session.get = Mock() self.session.session.get.return_value = FakeGetUsersGetResponse() get_users(self.session, query) self.assertTrue(self.session.session.get.called) query_params = self.session.session.get.call_args[1] self.assertIn(('users[]', [100, 200]), query_params['params'].items())