Skip to content

Commit e94bbec

Browse files
committed
Pre-commit clean up
1 parent fcf98e9 commit e94bbec

File tree

6 files changed

+124
-96
lines changed

6 files changed

+124
-96
lines changed

base/expected_conditions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ def __call__(self, driver):
3030

3131

3232
class text_to_be_present_in_elements(object):
33-
""" An expectation for checking if the given text is present in the
33+
"""An expectation for checking if the given text is present in the
3434
specified element.
3535
locator, text
3636
"""
37+
3738
def __init__(self, locator, text_):
3839
self.locator = locator
3940
self.text = text_
4041

4142
def __call__(self, driver: WebDriver):
4243
try:
43-
return any(self.text in element.text for element in driver.find_elements(*self.locator))
44+
return any(
45+
self.text in element.text
46+
for element in driver.find_elements(*self.locator)
47+
)
4448
except StaleElementReferenceException:
4549
return False

pages/counter.java

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
1-
import java.util.concurrent.ExecutorService;
2-
import java.util.concurrent.Executors;
1+
import java.util.concurrent.ExecutorService;
2+
import java.util.concurrent.Executors;
33

4-
/**
5-
* @author evivehealth on 08/02/19.
4+
/**
5+
* @author evivehealth on 08/02/19.
66
*/
7-
// Java program depicting
8-
// concurrent programming in action.
7+
// Java program depicting
8+
// concurrent programming in action.
99

10-
// Runnable Class that defines the logic
11-
// of run method of runnable interface
12-
public class Counter implements Runnable
13-
{
14-
private final MainApp mainApp;
15-
private final int loopLimit;
16-
private final String task;
10+
// Runnable Class that defines the logic
11+
// of run method of runnable interface
12+
public class Counter implements Runnable
13+
{
14+
private final MainApp mainApp;
15+
private final int loopLimit;
16+
private final String task;
1717

18-
// Constructor to get a reference to the main class
19-
public Counter
20-
(MainApp mainApp, int loopLimit, String task)
21-
{
22-
this.mainApp = mainApp;
23-
this.loopLimit = loopLimit;
24-
this.task = task;
25-
}
18+
// Constructor to get a reference to the main class
19+
public Counter
20+
(MainApp mainApp, int loopLimit, String task)
21+
{
22+
this.mainApp = mainApp;
23+
this.loopLimit = loopLimit;
24+
this.task = task;
25+
}
2626

27-
// Prints the thread name, task number and
28-
// the value of counter
29-
// Calls pause method to allow multithreading to occur
27+
// Prints the thread name, task number and
28+
// the value of counter
29+
// Calls pause method to allow multithreading to occur
3030
@Override
31-
public void run()
32-
{
33-
for (int i = 0; i < loopLimit; i++)
34-
{
35-
System.out.println("Thread: " +
31+
public void run()
32+
{
33+
for (int i = 0; i < loopLimit; i++)
34+
{
35+
System.out.println("Thread: " +
3636
Thread.currentThread().getName() + " Counter: "
37-
+ (i + 1) + " Task: " + task);
38-
mainApp.pause(Math.random());
39-
}
40-
}
41-
}
42-
class MainApp
43-
{
37+
+ (i + 1) + " Task: " + task);
38+
mainApp.pause(Math.random());
39+
}
40+
}
41+
}
42+
class MainApp
43+
{
4444

45-
// Starts the threads. Pool size 2 means at any time
46-
// there can only be two simultaneous threads
47-
public void startThread()
48-
{
49-
ExecutorService taskList =
50-
Executors.newFixedThreadPool(2);
51-
for (int i = 0; i < 5; i++)
52-
{
53-
// Makes tasks available for execution.
54-
// At the appropriate time, calls run
55-
// method of runnable interface
56-
taskList.execute(new Counter(this, i + 1,
57-
"task " + (i + 1)));
58-
}
45+
// Starts the threads. Pool size 2 means at any time
46+
// there can only be two simultaneous threads
47+
public void startThread()
48+
{
49+
ExecutorService taskList =
50+
Executors.newFixedThreadPool(2);
51+
for (int i = 0; i < 5; i++)
52+
{
53+
// Makes tasks available for execution.
54+
// At the appropriate time, calls run
55+
// method of runnable interface
56+
taskList.execute(new Counter(this, i + 1,
57+
"task " + (i + 1)));
58+
}
5959

60-
// Shuts the thread that's watching to see if
61-
// you have added new tasks.
62-
taskList.shutdown();
63-
}
60+
// Shuts the thread that's watching to see if
61+
// you have added new tasks.
62+
taskList.shutdown();
63+
}
6464

65-
// Pauses execution for a moment
66-
// so that system switches back and forth
67-
public void pause(double seconds)
68-
{
65+
// Pauses execution for a moment
66+
// so that system switches back and forth
67+
public void pause(double seconds)
68+
{
6969
try
70-
{
71-
Thread.sleep(Math.round(1000.0 * seconds));
72-
}
73-
catch (InterruptedException e)
74-
{
75-
e.printStackTrace();
76-
}
77-
}
70+
{
71+
Thread.sleep(Math.round(1000.0 * seconds));
72+
}
73+
catch (InterruptedException e)
74+
{
75+
e.printStackTrace();
76+
}
77+
}
7878

79-
// Driver method
80-
public static void main(String[] args)
81-
{
82-
new MainApp().startThread();
83-
}
84-
}
79+
// Driver method
80+
public static void main(String[] args)
81+
{
82+
new MainApp().startThread();
83+
}
84+
}

pages/institutions.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ class InstitutionAdminDashboardPage(BaseInstitutionPage):
6060
url_addition = '/dashboard'
6161

6262
identity = Locator(By.CSS_SELECTOR, 'img[alt="Center For Open Science [Test]"]')
63-
loading_indicator = Locator(
64-
By.CSS_SELECTOR, '.ball-scale', settings.LONG_TIMEOUT
65-
)
63+
loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale', settings.LONG_TIMEOUT)
6664
title_containers = GroupLocator(
6765
By.CSS_SELECTOR,
6866
'._title-container_1d9vmx',
@@ -84,28 +82,40 @@ class InstitutionAdminDashboardPage(BaseInstitutionPage):
8482
By.CSS_SELECTOR,
8583
'div._table-wrapper_1w5vdt > div > div.ember-view > div > div > table > tbody > tr',
8684
)
85+
8786
def get_expanded_total_by_expanded_name(self, department):
88-
for element in self.department_options:
89-
name_elem = element.find_element(By.CSS_SELECTOR, "[data-test-expanded-name]")
90-
if name_elem.text.strip() == department:
91-
total_elem = element.find_element(By.CSS_SELECTOR, "[data-test-expanded-total]")
87+
for element in self.department_options:
88+
name_elem = element.find_element(
89+
By.CSS_SELECTOR, '[data-test-expanded-name]'
90+
)
91+
if name_elem.text.strip() == department:
92+
total_elem = element.find_element(
93+
By.CSS_SELECTOR, '[data-test-expanded-total]'
94+
)
9295
return int(total_elem.text.strip())
9396

9497
def get_kpi_data_by_kpi_title(self, target_title):
9598
for container in self.kpi_container:
96-
title_element = container.find_element(By.CSS_SELECTOR, "[data-test-kpi-title]")
99+
title_element = container.find_element(
100+
By.CSS_SELECTOR, '[data-test-kpi-title]'
101+
)
97102
if title_element.text.strip() == target_title:
98-
value_element = container.find_element(By.CSS_SELECTOR, "[data-test-kpi-data]")
103+
value_element = container.find_element(
104+
By.CSS_SELECTOR, '[data-test-kpi-data]'
105+
)
99106
return value_element.text.strip()
100107

101108
def click_on_listbox_trigger(self, section_title):
102109
for section in self.title_containers:
103-
title_element = section.find_element(By.CSS_SELECTOR, "[data-test-chart-title]")
110+
title_element = section.find_element(
111+
By.CSS_SELECTOR, '[data-test-chart-title]'
112+
)
104113
if title_element.text.strip() == section_title:
105-
button = section.find_element(By.CSS_SELECTOR, "[data-test-expand-additional-data]")
106-
icon = section.find_element(By.CSS_SELECTOR, "[data-test-toggle-icon]")
114+
button = section.find_element(
115+
By.CSS_SELECTOR, '[data-test-expand-additional-data]'
116+
)
117+
icon = section.find_element(By.CSS_SELECTOR, '[data-test-toggle-icon]')
107118
button.click()
108119
WebDriverWait(self.driver, 10).until(
109-
lambda d: icon.get_attribute("data-icon") == "caret-up"
120+
lambda d: icon.get_attribute('data-icon') == 'caret-up'
110121
)
111-

pages/preprints.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ def select_from_dropdown_listbox(self, selection):
117117
def select_top_level_subject(self, selection):
118118
subject_selector = 'div[data-analytics-scope="Browse"] > ul > li'
119119
wait = WebDriverWait(self.driver, 5)
120-
wait.until(text_to_be_present_in_elements((By.CSS_SELECTOR, subject_selector), selection))
120+
wait.until(
121+
text_to_be_present_in_elements(
122+
(By.CSS_SELECTOR, subject_selector), selection
123+
)
124+
)
121125
for subject in self.top_level_subjects:
122126
if subject.text == selection:
123127
subject.click()

tests/test_institutions.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
import markers
34
from api import osf_api
45
from pages.institutions import (
@@ -58,7 +59,9 @@ def test_institution_admin_dashboard(self, driver, session, must_be_logged_in):
5859
api_public_project_count = metrics_data['attributes']['public_project_count']
5960
api_private_project_count = metrics_data['attributes']['private_project_count']
6061

61-
total_project_count = dashboard_page.get_kpi_data_by_kpi_title('OSF Public and Private Projects')
62+
total_project_count = dashboard_page.get_kpi_data_by_kpi_title(
63+
'OSF Public and Private Projects'
64+
)
6265

6366
# Verify Total User Count
6467
displayed_user_count = dashboard_page.get_kpi_data_by_kpi_title('Total Users')
@@ -67,14 +70,19 @@ def test_institution_admin_dashboard(self, driver, session, must_be_logged_in):
6770
dashboard_page.click_on_listbox_trigger('Public vs Private Projects')
6871

6972
# Verify Public Project Count
70-
displayed_public_project_count = dashboard_page.get_expanded_total_by_expanded_name('Public Projects')
73+
displayed_public_project_count = (
74+
dashboard_page.get_expanded_total_by_expanded_name('Public Projects')
75+
)
7176
assert int(displayed_public_project_count) == api_public_project_count
7277

7378
# Verify Private Project Count
74-
displayed_private_project_count = dashboard_page.get_expanded_total_by_expanded_name('Private Projects')
79+
displayed_private_project_count = (
80+
dashboard_page.get_expanded_total_by_expanded_name('Private Projects')
81+
)
7582
assert int(displayed_private_project_count) == api_private_project_count
7683

7784
# Verify Total Project Count
7885
assert (
79-
int(total_project_count) == api_public_project_count + api_private_project_count
86+
int(total_project_count)
87+
== api_public_project_count + api_private_project_count
8088
)

tests/test_preprints.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,15 @@ def test_edit_preprint(self, session, driver, preprint_detail_page):
283283
edit_page.basics_tags_input.send_keys(Keys.RETURN)
284284
# Click Return to preprint button to go back to Preprint Detail page
285285

286-
body = driver.find_element(By.TAG_NAME, "body")
286+
body = driver.find_element(By.TAG_NAME, 'body')
287287
body.send_keys(Keys.HOME)
288288
WebDriverWait(driver, 5).until(
289-
EC.invisibility_of_element_located((By.CLASS_NAME, "toast-success"))
289+
EC.invisibility_of_element_located((By.CLASS_NAME, 'toast-success'))
290290
)
291291
WebDriverWait(driver, 5).until(
292-
EC.visibility_of_element_located((By.CSS_SELECTOR, '[data-test-next-button]'))
292+
EC.visibility_of_element_located(
293+
(By.CSS_SELECTOR, '[data-test-next-button]')
294+
)
293295
)
294296
edit_page.next_button.click()
295297
WebDriverWait(driver, 5).until(

0 commit comments

Comments
 (0)