Skip to content

Commit

Permalink
Fix up pylint, pep8, and py26 errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff-Meadows committed Jul 2, 2015
1 parent aecb849 commit 5cbc924
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 27 deletions.
8 changes: 8 additions & 0 deletions docs/source/boxsdk.util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ boxsdk.util.ordered_dict module
:undoc-members:
:show-inheritance:

boxsdk.util.shared_link module
------------------------------

.. automodule:: boxsdk.util.shared_link
:members:
:undoc-members:
:show-inheritance:

boxsdk.util.singleton module
----------------------------

Expand Down
31 changes: 21 additions & 10 deletions test/integration/test_as_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

from __future__ import unicode_literals
from mock import call, patch
import pytest
from boxsdk.config import API
from boxsdk.object.group_membership import GroupMembership
from boxsdk.object.user import User


@pytest.fixture
def box_api_headers(mock_user_id, access_token):
return {'Authorization': 'Bearer {0}'.format(access_token), 'As-User': mock_user_id}


def test_client_as_user_causes_as_user_header_to_be_added(
box_client,
mock_box_network,
generic_successful_response,
mock_user_id,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -22,7 +29,7 @@ def test_client_as_user_causes_as_user_header_to_be_added(
call(
'GET',
'{0}/folders/0'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'As-User': mock_user_id},
headers=box_api_headers,
params=None,
),
]
Expand All @@ -33,8 +40,9 @@ def test_folder_object_as_user_causes_as_user_header_to_be_added(
mock_box_network,
generic_successful_response,
mock_user_id,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -43,7 +51,7 @@ def test_folder_object_as_user_causes_as_user_header_to_be_added(
call(
'GET',
'{0}/folders/0'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'As-User': mock_user_id},
headers=box_api_headers,
params=None,
),
]
Expand All @@ -54,8 +62,9 @@ def test_group_membership_object_as_user_causes_as_user_header_to_be_added(
mock_box_network,
generic_successful_response,
mock_user_id,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -66,7 +75,7 @@ def test_group_membership_object_as_user_causes_as_user_header_to_be_added(
call(
'GET',
'{0}/group_memberships/0'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'As-User': mock_user_id},
headers=box_api_headers,
params=None,
),
]
Expand All @@ -77,8 +86,9 @@ def test_events_endpoint_as_user_causes_as_user_header_to_be_added(
mock_box_network,
generic_successful_response,
mock_user_id,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -89,7 +99,7 @@ def test_events_endpoint_as_user_causes_as_user_header_to_be_added(
call(
'GET',
options['url'],
headers={'Authorization': 'Bearer {}'.format(access_token), 'As-User': mock_user_id},
headers=box_api_headers,
timeout=options['retry_timeout'],
params={'stream_position': stream_position},
),
Expand All @@ -101,8 +111,9 @@ def test_metadata_endpoint_as_user_causes_as_user_header_to_be_added(
mock_box_network,
generic_successful_response,
mock_user_id,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -111,6 +122,6 @@ def test_metadata_endpoint_as_user_causes_as_user_header_to_be_added(
call(
'GET',
'{0}/files/0/metadata/global/properties'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'As-User': mock_user_id},
headers=box_api_headers,
),
]
37 changes: 20 additions & 17 deletions test/integration/test_with_shared_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ def shared_link_password(request):


@pytest.fixture
def box_api_header(shared_link, shared_link_password):
return get_shared_link_header(shared_link, shared_link_password)['BoxApi']
def box_api_headers(shared_link, shared_link_password, access_token):
# pylint:disable=redefined-outer-name
box_api_header = get_shared_link_header(shared_link, shared_link_password)['BoxApi']
return {'Authorization': 'Bearer {0}'.format(access_token), 'BoxApi': box_api_header}


def test_client_with_shared_link_causes_box_api_header_to_be_added(
box_client,
mock_box_network,
generic_successful_response,
shared_link,
shared_link_password,
box_api_header,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -39,7 +42,7 @@ def test_client_with_shared_link_causes_box_api_header_to_be_added(
call(
'GET',
'{0}/folders/0'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'BoxApi': box_api_header},
headers=box_api_headers,
params=None,
),
]
Expand All @@ -51,9 +54,9 @@ def test_folder_object_with_shared_link_causes_box_api_header_to_be_added(
generic_successful_response,
shared_link,
shared_link_password,
box_api_header,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -62,7 +65,7 @@ def test_folder_object_with_shared_link_causes_box_api_header_to_be_added(
call(
'GET',
'{0}/folders/0'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'BoxApi': box_api_header},
headers=box_api_headers,
params=None,
),
]
Expand All @@ -74,9 +77,9 @@ def test_group_membership_object_with_shared_link_causes_box_api_header_to_be_ad
generic_successful_response,
shared_link,
shared_link_password,
box_api_header,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -87,7 +90,7 @@ def test_group_membership_object_with_shared_link_causes_box_api_header_to_be_ad
call(
'GET',
'{0}/group_memberships/0'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'BoxApi': box_api_header},
headers=box_api_headers,
params=None,
),
]
Expand All @@ -99,9 +102,9 @@ def test_events_endpoint_with_shared_link_causes_box_api_header_to_be_added(
generic_successful_response,
shared_link,
shared_link_password,
box_api_header,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -112,7 +115,7 @@ def test_events_endpoint_with_shared_link_causes_box_api_header_to_be_added(
call(
'GET',
options['url'],
headers={'Authorization': 'Bearer {}'.format(access_token), 'BoxApi': box_api_header},
headers=box_api_headers,
timeout=options['retry_timeout'],
params={'stream_position': stream_position},
),
Expand All @@ -125,9 +128,9 @@ def test_metadata_endpoint_with_shared_link_causes_box_api_header_to_be_added(
generic_successful_response,
shared_link,
shared_link_password,
box_api_header,
access_token,
box_api_headers,
):
# pylint:disable=redefined-outer-name
mock_box_network.session.request.side_effect = [
generic_successful_response,
]
Expand All @@ -136,6 +139,6 @@ def test_metadata_endpoint_with_shared_link_causes_box_api_header_to_be_added(
call(
'GET',
'{0}/files/0/metadata/global/properties'.format(API.BASE_API_URL),
headers={'Authorization': 'Bearer {}'.format(access_token), 'BoxApi': box_api_header},
headers=box_api_headers,
),
]
1 change: 1 addition & 0 deletions test/unit/util/test_shared_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def password(request):


def test_get_shared_link_header(shared_link, password):
# pylint:disable=redefined-outer-name
header = get_shared_link_header(shared_link, password)
assert 'BoxApi' in header
assert shared_link in header['BoxApi']
Expand Down

0 comments on commit 5cbc924

Please sign in to comment.