Skip to content

Commit f612bac

Browse files
committed
break down the interactions tests into separate tests #38
1 parent dae20a6 commit f612bac

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

tests/test_interactions.py

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import importlib
2424
import time
2525
import json
26+
import platform
2627

2728
from .IntegrationTests import IntegrationTests
2829
from selenium.webdriver.common.by import By
@@ -40,7 +41,30 @@ def setUpClass(cls):
4041
app = importlib.import_module('usage-events').app
4142
cls.startServer(cls, app)
4243
WebDriverWait(cls.driver, 20).until(EC.presence_of_element_located((By.ID, "cytoscape")))
44+
cls.actions = ActionChains(cls.driver)
45+
cls.init_pos = {
46+
'Node 1': (59, 182),
47+
'Node 2': (222, 345),
48+
'Node 3': (168, 283 - 20),
49+
'Node 4': (440, 182),
50+
'Node 5': (277, 236),
51+
'Node 6': (168, 283)
52+
}
4353

54+
@classmethod
55+
def tearDownClass(cls):
56+
super(Tests, cls).tearDownClass()
57+
58+
time.sleep(3)
59+
if platform.system() == 'Windows':
60+
cls.driver.get('http://localhost:8050/stop')
61+
else:
62+
cls.server_process.terminate()
63+
time.sleep(3)
64+
cls.driver.quit()
65+
66+
def tearDown(self):
67+
pass
4468

4569
def save_screenshot(self, dir_name, name):
4670
directory_path = os.path.join(
@@ -130,24 +154,14 @@ def perform_mouseover(self, x, y, elem, actions, dir_name='interactions'):
130154

131155
return mouseover_label
132156

133-
def test_interactions(self):
134-
# VARIABLES
157+
def test_dragging(self):
135158
drag_error = "Unable to drag Cytoscape nodes properly"
136-
click_error = "Unable to click Cytoscape nodes properly"
137-
mouseover_error = "Unable to mouseover Cytoscape nodes properly"
138159

139160
# View module docstring for more information about initial positions
140-
init_pos = {
141-
'Node 1': (59, 182),
142-
'Node 2': (222, 345),
143-
'Node 3': (168, 283 - 20),
144-
'Node 4': (440, 182),
145-
'Node 5': (277, 236),
146-
'Node 6': (168, 283)
147-
}
161+
init_pos = self.init_pos
148162
init_x, init_y = init_pos['Node 1']
149163

150-
actions = ActionChains(self.driver)
164+
actions = self.actions
151165

152166
# Select the JSON output element
153167
elem_tap = self.driver.find_element_by_css_selector('pre#tap-node-json-output')
@@ -164,11 +178,24 @@ def test_interactions(self):
164178
assert self.perform_dragging(init_x+150, init_y+150, -150, -150, elem_tap, actions) == \
165179
(-150, -150), drag_error
166180

181+
def test_clicking(self):
182+
click_error = "Unable to click Cytoscape nodes properly"
183+
actions = self.actions
184+
185+
# Select the JSON output element
186+
elem_tap = self.driver.find_element_by_css_selector('pre#tap-node-json-output')
187+
188+
init_pos = self.init_pos
167189
# Test clicking the nodes
168190
for i in range(1, 7):
169191
label = 'Node {}'.format(i)
170192
assert self.perform_clicking(*init_pos[label], elem_tap, actions) == label, click_error
171193

194+
def test_mouseover(self):
195+
init_pos = self.init_pos
196+
mouseover_error = "Unable to mouseover Cytoscape nodes properly"
197+
actions = self.actions
198+
172199
# Open the Mouseover JSON tab
173200
actions.move_to_element(
174201
self.driver.find_element_by_css_selector('#tabs > div:nth-child(3)'))

0 commit comments

Comments
 (0)