Skip to content

Commit dcec67c

Browse files
committed
Update black and isort linting tools
1 parent 617fa8a commit dcec67c

20 files changed

+103
-113
lines changed

api/osf_api.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ def delete_all_user_projects(session, user=None):
121121

122122

123123
def delete_project(session, guid, user=None):
124-
"""Delete a single project. Simply pass in the guid
125-
"""
124+
"""Delete a single project. Simply pass in the guid"""
126125
if not user:
127126
user = current_user(session)
128127
nodes_url = user.relationships.nodes['links']['related']['href']
@@ -135,8 +134,7 @@ def delete_project(session, guid, user=None):
135134

136135

137136
def create_custom_collection(session):
138-
"""Create a new custom collection. You can modify the title of the collection here as well.
139-
"""
137+
"""Create a new custom collection. You can modify the title of the collection here as well."""
140138
collections_url = '{}/v2/collections/'.format(session.api_base_url)
141139

142140
payload = {
@@ -147,8 +145,7 @@ def create_custom_collection(session):
147145

148146

149147
def delete_custom_collections(session):
150-
"""Delete all custom collections for the current user.
151-
"""
148+
"""Delete all custom collections for the current user."""
152149
collections_url = '{}/v2/collections/'.format(session.api_base_url)
153150
data = session.get(collections_url)
154151

@@ -161,8 +158,7 @@ def delete_custom_collections(session):
161158
# TODO rename this to get_node_providers, and create new function that actually IS get_node_addons -
162159
# note, this is confusing, talk to BrianG before we change this
163160
def get_node_addons(session, node_id):
164-
"""Return a list of the names of all the addons connected to the given node.
165-
"""
161+
"""Return a list of the names of all the addons connected to the given node."""
166162
url = '/v2/nodes/{}/files/'.format(node_id)
167163
data = session.get(url, query_parameters={'page[size]': 20})
168164
providers = []
@@ -222,8 +218,7 @@ def upload_fake_file(
222218

223219

224220
def delete_addon_files(session, provider, current_browser, guid):
225-
"""Delete all files for the given addon.
226-
"""
221+
"""Delete all files for the given addon."""
227222
files_url = '{}/v2/nodes/{}/files/{}/'.format(session.api_base_url, guid, provider)
228223

229224
data = session.get(url=files_url, query_parameters={'page[size]': 20})
@@ -245,8 +240,7 @@ def delete_file(session, delete_url):
245240

246241

247242
def get_providers_list(session=None, type='preprints'):
248-
"""Return the providers list data. The default is the preprint providers list.
249-
"""
243+
"""Return the providers list data. The default is the preprint providers list."""
250244
if not session:
251245
session = get_default_session()
252246
url = '/v2/providers/' + type
@@ -265,14 +259,13 @@ def get_provider(session=None, type='registrations', provider_id='osf'):
265259

266260

267261
def get_provider_submission_status(provider):
268-
"""Return the boolean attribute `allow_submissions` from the dictionary object (provider)
269-
"""
262+
"""Return the boolean attribute `allow_submissions` from the dictionary object (provider)"""
270263
return provider['attributes']['allow_submissions']
271264

272265

273266
def get_providers_total(provider_name, session):
274-
""" Return the total number of preprints for a given service provider.
275-
Note: Reformat provider names to all lowercase and remove white spaces.
267+
"""Return the total number of preprints for a given service provider.
268+
Note: Reformat provider names to all lowercase and remove white spaces.
276269
"""
277270
provider_url = '/v2/providers/preprints/{}/preprints/'.format(
278271
provider_name.lower().replace(' ', '')
@@ -281,7 +274,10 @@ def get_providers_total(provider_name, session):
281274

282275

283276
def connect_provider_root_to_node(
284-
session, provider, external_account_id, node_id=settings.PREFERRED_NODE,
277+
session,
278+
provider,
279+
external_account_id,
280+
node_id=settings.PREFERRED_NODE,
285281
):
286282
"""Initialize the node<=>addon connection, add the given external_account_id, and configure it
287283
to connect to the root folder of the provider."""

base/exceptions.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class HttpError(PageException):
77

88

99
class LoginError(PageException):
10-
"""Error used when driver is in an unexpected login state.
11-
"""
10+
"""Error used when driver is in an unexpected login state."""
1211

1312
pass

base/expected_conditions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class link_has_href(object):
5-
""" An Expectation for checking link is visible and has an href so
5+
"""An Expectation for checking link is visible and has an href so
66
you can click it."""
77

88
def __init__(self, locator):
@@ -17,7 +17,7 @@ def __call__(self, driver):
1717

1818

1919
class window_at_index(object):
20-
""" An Expectation for checking if a tab is open for certain index
20+
"""An Expectation for checking if a tab is open for certain index
2121
so you can switch to it."""
2222

2323
def __init__(self, page_index):

base/locators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ def __init__(self, selector, path, timeout=settings.TIMEOUT):
128128

129129
def get_element(self, driver, attribute_name):
130130
"""Must be implemented by every Locator subclass. Defines how a locator is used within
131-
a page (or element). Ultimately is a locator's return value when used in the PageObject model.
132-
"""
131+
a page (or element). Ultimately is a locator's return value when used in the PageObject model.
132+
"""
133133
raise NotImplementedError
134134

135135

components/accessibility.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ def run_axe(
1515
terminal_errors=True,
1616
exclude_best_practice=False,
1717
):
18-
""" Use the axe testing engine to perform accessibility checks on a web page
19-
Parameters:
20-
- page_name - string - unique identifier for the web page being tested
21-
- used as part of file name when writing results files
22-
- write_files - boolean - used to determine whether or not to write results
23-
files - default = True
24-
- terminal_errors - boolean - used to determine whether or not to output
25-
errors to terminal window - default = True
26-
- exclude_best_practice - boolean - used to determine whether or not to
27-
exclude the Best Practice rule set when performing accessibility check.
28-
- default = False
18+
"""Use the axe testing engine to perform accessibility checks on a web page
19+
Parameters:
20+
- page_name - string - unique identifier for the web page being tested
21+
- used as part of file name when writing results files
22+
- write_files - boolean - used to determine whether or not to write results
23+
files - default = True
24+
- terminal_errors - boolean - used to determine whether or not to output
25+
errors to terminal window - default = True
26+
- exclude_best_practice - boolean - used to determine whether or not to
27+
exclude the Best Practice rule set when performing accessibility check.
28+
- default = False
2929
"""
3030
axe = Axe(driver)
3131
# Inject axe-core javascript into page.
@@ -76,7 +76,7 @@ def run_axe(
7676

7777

7878
def write_results_files(axe, results, page_name):
79-
""" Write results to output .json files (3 separate files for passes, violations,
79+
"""Write results to output .json files (3 separate files for passes, violations,
8080
and incomplete) and also convert each .json file to a .csv file. So there should
8181
be 6 separate files created for each execution of axe. We are using the Panda
8282
library to convert .json to .csv files.

components/email_access.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class EmailAccess:
55
def get_latest_email_body_by_imap(
66
imap_host, email_address, password, mailbox, search_key, search_value
77
):
8-
""" This method uses Internet Message Access Protocol (IMAP) to login to an IMAP
8+
"""This method uses Internet Message Access Protocol (IMAP) to login to an IMAP
99
enabled email address and retrieve the body of the latest email that matches the
1010
provided search criteria.
1111
Parameters:
@@ -37,7 +37,7 @@ def get_latest_email_body_by_imap(
3737
return email_body
3838

3939
def get_count_of_unseen_emails_by_imap(imap_host, email_address, password):
40-
""" This method uses Internet Message Access Protocol (IMAP) to login to an IMAP
40+
"""This method uses Internet Message Access Protocol (IMAP) to login to an IMAP
4141
enabled email address and retrieve the count of unseen emails in the account inbox.
4242
Parameters:
4343
- imap_host: host imap email server
@@ -59,29 +59,29 @@ def get_count_of_unseen_emails_by_imap(imap_host, email_address, password):
5959

6060

6161
def imap_connect_and_login(imap_host, email_address, password):
62-
""" Function to make SSL connection to IMP host and login with the given credentials
63-
Parameters:
64-
- imap_host: host imap email server
65-
- email_address: IMAP enabled email address
66-
- password: password for the IMAP enabled email address
67-
Returns IMAP connected object
62+
"""Function to make SSL connection to IMP host and login with the given credentials
63+
Parameters:
64+
- imap_host: host imap email server
65+
- email_address: IMAP enabled email address
66+
- password: password for the IMAP enabled email address
67+
Returns IMAP connected object
6868
"""
6969
imap = imaplib.IMAP4_SSL(imap_host)
7070
imap.login(email_address, password)
7171
return imap
7272

7373

7474
def imap_close(imap):
75-
""" Function that closes the current email mailbox and logs out of the email account
76-
Parameters:
77-
- imap: IMAP connected object
75+
"""Function that closes the current email mailbox and logs out of the email account
76+
Parameters:
77+
- imap: IMAP connected object
7878
"""
7979
imap.close()
8080
imap.logout()
8181

8282

8383
def search(key, value, imap):
84-
""" Function to search through emails for a given key value pair and return a
84+
"""Function to search through emails for a given key value pair and return a
8585
filtered email list.
8686
EX: result_uids = search('FROM', '[email protected]', con)
8787
Parameters:

pages/collections.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99

1010
class BaseCollectionPage(OSFBasePage):
11-
"""The base page from which all collection pages inherit.
12-
"""
11+
"""The base page from which all collection pages inherit."""
1312

1413
base_url = settings.OSF_HOME + '/collections/'
1514
url_addition = ''
@@ -24,8 +23,7 @@ def __init__(self, driver, verify=False, provider=None):
2423

2524
@property
2625
def url(self):
27-
"""Set the URL based on the provider domain.
28-
"""
26+
"""Set the URL based on the provider domain."""
2927
return urljoin(self.base_url, self.provider_id) + '/' + self.url_addition
3028

3129

pages/login.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ def login(driver, user=settings.USER_ONE, password=settings.USER_ONE_PASSWORD):
150150

151151

152152
def safe_login(driver, user=settings.USER_ONE, password=settings.USER_ONE_PASSWORD):
153-
"""Raise a LoginError if login fails.
154-
"""
153+
"""Raise a LoginError if login fails."""
155154
login(driver, user=user, password=password)
156155
if not OSFBasePage(driver).is_logged_in():
157156
raise LoginError('Login failed')
158157

159158

160159
def logout(driver):
161-
"""Log the user out.
162-
"""
160+
"""Log the user out."""
163161
driver.get(settings.OSF_HOME + '/logout/')

pages/preprints.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111

1212
class BasePreprintPage(OSFBasePage):
13-
"""The base page from which all preprint pages inherit.
14-
"""
13+
"""The base page from which all preprint pages inherit."""
1514

1615
base_url = settings.OSF_HOME + '/preprints/'
1716
url_addition = ''
@@ -28,8 +27,7 @@ def __init__(self, driver, verify=False, provider=None):
2827

2928
@property
3029
def url(self):
31-
"""Set the URL based on the provider domain.
32-
"""
30+
"""Set the URL based on the provider domain."""
3331
if self.provider and self.provider_id != 'osf':
3432
if self.provider['attributes']['domain_redirect_enabled']:
3533
return urljoin(self.provider_domain, self.url_addition)
@@ -181,8 +179,7 @@ class ReviewsDashboardPage(OSFBasePage):
181179

182180

183181
class BaseReviewsPage(OSFBasePage):
184-
"""The base page from which all preprint provider review pages inherit.
185-
"""
182+
"""The base page from which all preprint provider review pages inherit."""
186183

187184
base_url = settings.OSF_HOME + '/reviews/preprints/'
188185
url_addition = ''
@@ -199,8 +196,7 @@ def __init__(self, driver, verify=False, provider=None):
199196

200197
@property
201198
def url(self):
202-
"""Set the URL based on the provider domain.
203-
"""
199+
"""Set the URL based on the provider domain."""
204200
return urljoin(self.base_url, self.provider_id) + '/' + self.url_addition
205201

206202
def verify(self):

pages/registries.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def __init__(self, driver, verify=False, provider=None):
2424

2525
@property
2626
def url(self):
27-
"""Set the URL based on the provider
28-
"""
27+
"""Set the URL based on the provider"""
2928
if self.provider and self.provider_id != 'osf':
3029
return urljoin(self.base_url, self.provider_id) + '/' + self.url_addition
3130
return self.base_url + self.url_addition
@@ -170,5 +169,7 @@ def __init__(self, driver, verify=False, draft_id='', url_addition=''):
170169
class DraftRegistrationReviewPage(BaseRegistrationDraftPage):
171170
url_addition = 'review'
172171
identity = Locator(
173-
By.CSS_SELECTOR, '[data-test-toggle-anchor-nav-button]', settings.LONG_TIMEOUT,
172+
By.CSS_SELECTOR,
173+
'[data-test-toggle-anchor-nav-button]',
174+
settings.LONG_TIMEOUT,
174175
)

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ pre-commit==1.18.3
1212
ipdb==0.12.2
1313
axe-selenium-python==2.1.6
1414
pandas==1.2.4
15-
isort==5.8.0
16-
black==19.10b0
15+
isort==5.9.3
16+
black==22.3.0

tests/conftest.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def delete_user_projects_at_setup(session):
7878
@pytest.fixture
7979
def default_project(session):
8080
"""Creates a new project through the api and returns it. Deletes the project at the end of the test run.
81-
If PREFERRED_NODE is set, returns the APIDetail of preferred node.
82-
"""
81+
If PREFERRED_NODE is set, returns the APIDetail of preferred node.
82+
"""
8383
if settings.PREFERRED_NODE:
8484
yield osf_api.get_node(session)
8585
else:
@@ -115,8 +115,7 @@ def project_with_file(session, default_project):
115115

116116

117117
def pytest_addoption(parser):
118-
"""Accept input parameters when running pytest from command line
119-
"""
118+
"""Accept input parameters when running pytest from command line"""
120119
# Flag to determine whether to write accessibility output files
121120
parser.addoption('--write_files', action='store')
122121
# Flag to determine whether to exclude Best Practice rules from accessibility check

tests/test_a11y_cas.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_accessibility(self, driver, session, write_files, exclude_best_practice
3232

3333
@markers.dont_run_on_prod
3434
class TestLogin2FAPage:
35-
""" This test logs in as a user with 2 Factor Authentication enabled. After entering
35+
"""This test logs in as a user with 2 Factor Authentication enabled. After entering
3636
their login credentials as normal the user is then directed to a 2 Factor Authentication
3737
page.
3838
"""
@@ -53,7 +53,7 @@ def test_accessibility(self, driver, session, write_files, exclude_best_practice
5353

5454
@markers.dont_run_on_prod
5555
class TestLoginToSPage:
56-
""" This test logs in as a user that has not accepted the OSF Terms of Service. After
56+
"""This test logs in as a user that has not accepted the OSF Terms of Service. After
5757
entering their login credentials as normal the user is then directed to a Terms of
5858
Service acceptance page.
5959
"""
@@ -124,7 +124,7 @@ def test_accessibility(self, driver, session, write_files, exclude_best_practice
124124

125125

126126
class TestInstitutionForgotPasswordPage:
127-
""" Test the Forgot Password page that is reached from the Unsupported Institution
127+
"""Test the Forgot Password page that is reached from the Unsupported Institution
128128
Login Page. This Forgot Password page is different from the other Forgot Password
129129
page in OSF.
130130
"""
@@ -148,8 +148,7 @@ def test_accessibility(self, driver, session, write_files, exclude_best_practice
148148

149149
class TestGenericCASExceptionPage:
150150
def test_accessibility(self, driver, session, write_files, exclude_best_practice):
151-
""" Test the Service not authorized exception page by having an invalid service in the url
152-
"""
151+
"""Test the Service not authorized exception page by having an invalid service in the url"""
153152
driver.get(settings.CAS_DOMAIN + '/login?service=https://noservice.osf.io/')
154153
assert GenericCASPage(driver, verify=True)
155154
a11y.run_axe(
@@ -166,7 +165,7 @@ class TestCASOauthAuthorizationPage:
166165
def test_accessibility(
167166
self, driver, session, write_files, exclude_best_practice, must_be_logged_in
168167
):
169-
""" Test the CAS Oauth Authorization page by building an authorization url using
168+
"""Test the CAS Oauth Authorization page by building an authorization url using
170169
the required parameters and then navigating to that url. No need to complete the
171170
authorization process since we just want to evaluate the authorization page for
172171
accessibility compliance.

0 commit comments

Comments
 (0)