Skip to content

Commit 7136938

Browse files
authored
Merge pull request #21 from mwang87/selenium_tests2
selenium test update
2 parents 2ef9efe + bbe4d38 commit 7136938

File tree

9 files changed

+88
-16
lines changed

9 files changed

+88
-16
lines changed

.github/workflows/productionintegration.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
- name: Install dependencies
1919
run: |
2020
python -m pip install --upgrade pip
21-
pip install requests
21+
pip install requests nose2 selenium
2222
- name: Test with pytest
2323
run: |
24-
pip install nose2
25-
cd test-production-integration && nose2 -v
24+
cd test-production-integration && nose2 -v test_selenium

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test-push:
2+
act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04
3+
test-schedule:
4+
act schedule -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ We have unit tests to test the validators. There are several naming conventions:
2525
1. ```invalid_*``` - These are invalid files that fail validation
2626
1. ```invaliddata_*``` - These are valid files that pass validation but fail to match with data in MassIVE
2727

28+
To run all unit tests, we are using [act](https://github.com/nektos/act) to run github actions locally:
29+
30+
```make test-push```
31+
32+
to simulate a push to the repository and run the full suite of unit tests exactly as we'd run at github.
33+
34+
To simulate selenium and production integration tests:
35+
36+
```make test-schedule```
37+
2838
## Updating ReDU Data Procedure
2939

3040
One of the key steps in ReDU is the updating of the database to include the latest identifications for files within ReDU. These are the following steps:

code/templates/compoundenrichment.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@ <h2 class="text-center">Chemical Enrichment Query Interface</h2>
2020
<input class="form-control" type="text" placeholder="Enter Compound Name" id="compound">
2121
</div>
2222
</div>
23-
<div><button class="btn btn-primary btn-block" onclick="querycompound()">Query Compound</button></div>
23+
<div id=querycompound><button class="btn btn-primary btn-block" onclick="querycompound()">Query Compound</button></div>
2424
</div>
2525

26-
<div id="charts"></div>
26+
<hr>
27+
28+
<div class="row">
29+
<div class="col-sm-1"></div>
30+
<div class="col-sm-12 text-center">
31+
<div id="charts"></div>
32+
</div>
33+
<div class="col-sm-1"></div>
34+
</div>
35+
36+
<hr>
2737

2838
<div class="table table-striped">
2939
<table id="datatable" class="display" width="100%"></table>

code/templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</div>
8181

8282
<div class="footer-copyright text-center py-3">
83-
ReDU - Release 11
83+
ReDU - Release 11.1
8484
</div>
8585

8686
<style>

code/views.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,23 +444,16 @@ def compoundenrichment():
444444

445445
for attribute in all_attributes:
446446
filtered_df = enrichment_df[enrichment_df["attribute_name"] == attribute]
447+
filtered_df = filtered_df[filtered_df["percentage"] > 0]
447448

448449
all_terms = list(filtered_df["attribute_term"])
449450
all_percentage = list(filtered_df["percentage"])
450-
plot = figure(x_range=all_terms, plot_height=600, plot_width=900, title="{} Percentage of Terms".format(attribute))
451+
plot = figure(x_range=all_terms, plot_height=300, plot_width=1200, sizing_mode="scale_width", title="{} Percentage of Terms".format(attribute))
451452
plot.vbar(x=all_terms, top=all_percentage, width=0.9)
452453
tab = Panel(child=plot, title=attribute)
453454

454455
all_tabs.append(tab)
455456

456-
# script, div = components(plot)
457-
458-
# draw_dict = {}
459-
# draw_dict["script"] = script
460-
# draw_dict["div"] = div
461-
462-
# drawing_dict[attribute] = draw_dict
463-
464457
tabs = Tabs(tabs=all_tabs)
465458
script, div = components(tabs)
466459

examples/ExtendedDataFigure2/Emperor_Human_ProjectRABloodPlasma_2D_PC1v3_emperor-settings.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/ExtendedDataFigure2/emperor-settings.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import time
2+
import json
3+
from selenium import webdriver
4+
from selenium.webdriver.common.by import By
5+
from selenium.webdriver.common.action_chains import ActionChains
6+
from selenium.webdriver.support import expected_conditions as EC
7+
from selenium.webdriver.support.wait import WebDriverWait
8+
from selenium.webdriver.common.keys import Keys
9+
import unittest, time, re
10+
import os
11+
12+
SERVER_URL = os.environ.get("SERVER_URL", "https://redu.ucsd.edu")
13+
14+
class TestInterfaceready(unittest.TestCase):
15+
def setUp(self):
16+
options = webdriver.ChromeOptions()
17+
options.add_argument('headless')
18+
#self.driver = webdriver.Chrome(options=options)
19+
self.driver = webdriver.PhantomJS()
20+
self.driver.implicitly_wait(30)
21+
self.vars = {}
22+
23+
def tearDown(self):
24+
self.driver.quit()
25+
26+
def test_compound_enrichment(self):
27+
#going to the page
28+
url = "{}/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE".format(SERVER_URL)
29+
print(url)
30+
self.driver.get(url)
31+
time.sleep(1)
32+
33+
wait = WebDriverWait(self.driver, 180)
34+
35+
#waiting for the modal to go aay
36+
wait.until(EC.invisibility_of_element_located((By.ID, 'loadMe')))
37+
38+
#waiting for the button to be clickable
39+
wait.until(EC.element_to_be_clickable((By.ID,'querycompound')))
40+
41+
#clicking the button
42+
python_button = self.driver.find_element(By.ID, 'querycompound')
43+
44+
python_button.click()
45+
#time.sleep(60)
46+
47+
try:
48+
alert = self.driver.switch_to.alert
49+
alert.accept()
50+
print("alert present, error")
51+
return 1
52+
except Exception:
53+
print("no alert, passing")
54+
55+
if __name__ == "__main__":
56+
unittest.main()

0 commit comments

Comments
 (0)