-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestMPM_upload.py
128 lines (111 loc) · 4.44 KB
/
testMPM_upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import os, platform, unittest, urllib.request
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions
from BaseTest import WorkflowTest, WithFirefox, WithChrome, username
class RunMPMWorkflow(WorkflowTest):
def test_tutorial(self):
run = self.runUploadedWorkflow(
'BioVeL_POP_MPM/matrix_population_model_analysis_v10.t2flow',
'Population Modelling',
textInputs=self.textInputs,
fileInputs=self.fileInputs
)
with run.waitForInteraction(300, 1):
confirm = self.portal.wait(60).until(
expected_conditions.presence_of_element_located(
(By.XPATH, '//*[@id="submit"]/input[@value="Confirm"]')
)
)
rows = self.portal.find_elements_by_xpath('//*[@id="content"]/tr')
self.assertTrue(rows, 'no interaction stage rows found')
for tr in rows:
stage = tr.find_element_by_xpath('./td[1]').text
self.assertIn(stage, self.abundances)
if stage in ('S', 'J'):
recruited = tr.find_element_by_xpath('./td[2]/input[@type="checkbox"]')
recruited.click()
self.pause(0.5)
elif stage == 'G':
reproductive = tr.find_element_by_xpath('./td[3]/input[@type="checkbox"]')
reproductive.click()
self.pause(0.5)
self.pause(1)
confirm.click()
with run.waitForInteraction(300, 1):
confirm = self.portal.wait(60).until(
expected_conditions.presence_of_element_located(
(By.XPATH, '//*[@id="content"]/input[@value="Confirm"]')
)
)
rows = self.portal.find_elements_by_xpath('//*[@id="content"]/div')
self.assertTrue(rows, 'no interaction abundance rows found')
for div in rows:
stage = div.find_element_by_tag_name('label').text
self.assertIn(stage, self.abundances)
textbox = div.find_element_by_tag_name('input')
textbox.send_keys(Keys.BACK_SPACE + str(self.abundances[stage]))
self.pause(0.5)
self.pause(0.5)
confirm.click()
results = run.waitForFinish(300, 1)
for result in results.values():
if result.getMimeType() == 'application/x-error':
self.fail(result.getValue())
class MPMDefaultInputs:
textInputs = None
fileInputs = None
abundances = {
'S': 69,
'J': 111,
'V': 100,
'G': 21,
'D': 43
}
class MPMTutorialInputs:
textInputs = {
'iterations': 1000
}
fileInputs = {
'stageMatrixFile': os.path.join(os.getcwd(), 'BioVeL_POP_MPM/MTers87_88.txt')
}
abundances = {
'S': 69,
'J': 111,
'V': 100,
'G': 21,
'D': 43
}
# Firefox on Windows hangs on click of Workflow Submit button using Selenium, but
# not when running workflow manually
# confirmed on (FF27.0.1, Win7)
@unittest.skipIf(platform.system() == 'Windows', 'Selenium hangs with Firefox on Windows')
@unittest.skipUnless(username, 'No username login provided')
class RunMPMDefaultFirefox(MPMDefaultInputs, RunMPMWorkflow, unittest.TestCase, WithFirefox):
pass
if WithChrome:
@unittest.skipUnless(username, 'No username login provided')
class RunMPMDefaultChrome(MPMDefaultInputs, RunMPMWorkflow, unittest.TestCase, WithChrome):
pass
# Firefox on Windows hangs on click of Workflow Submit button using Selenium, but
# not when running workflow manually
# confirmed on (FF27.0.1, Win7)
@unittest.skipIf(platform.system() == 'Windows', 'Selenium hangs with Firefox on Windows')
@unittest.skipUnless(username, 'No username login provided')
class RunMPMTutorialFirefox(MPMTutorialInputs, RunMPMWorkflow, unittest.TestCase, WithFirefox):
pass
if WithChrome:
@unittest.skipUnless(username, 'No username login provided')
class RunMPMTutorialChrome(MPMTutorialInputs, RunMPMWorkflow, unittest.TestCase, WithChrome):
pass
if __name__ == '__main__':
import sys
i = 1
while i < len(sys.argv):
arg = sys.argv[i]
if arg == '--pause':
pause = True
del sys.argv[i]
else:
i += 1
unittest.main()