Skip to content

Commit

Permalink
Merge pull request #21 from mwang87/selenium_tests2
Browse files Browse the repository at this point in the history
selenium test update
  • Loading branch information
cmaceves committed Apr 1, 2020
2 parents 2ef9efe + bbe4d38 commit 7136938
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 16 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/productionintegration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
pip install requests nose2 selenium
- name: Test with pytest
run: |
pip install nose2
cd test-production-integration && nose2 -v
cd test-production-integration && nose2 -v test_selenium
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test-push:
act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04
test-schedule:
act schedule -P ubuntu-latest=nektos/act-environments-ubuntu:18.04
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ We have unit tests to test the validators. There are several naming conventions:
1. ```invalid_*``` - These are invalid files that fail validation
1. ```invaliddata_*``` - These are valid files that pass validation but fail to match with data in MassIVE

To run all unit tests, we are using [act](https://github.com/nektos/act) to run github actions locally:

```make test-push```

to simulate a push to the repository and run the full suite of unit tests exactly as we'd run at github.

To simulate selenium and production integration tests:

```make test-schedule```

## Updating ReDU Data Procedure

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:
Expand Down
14 changes: 12 additions & 2 deletions code/templates/compoundenrichment.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ <h2 class="text-center">Chemical Enrichment Query Interface</h2>
<input class="form-control" type="text" placeholder="Enter Compound Name" id="compound">
</div>
</div>
<div><button class="btn btn-primary btn-block" onclick="querycompound()">Query Compound</button></div>
<div id=querycompound><button class="btn btn-primary btn-block" onclick="querycompound()">Query Compound</button></div>
</div>

<div id="charts"></div>
<hr>

<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-12 text-center">
<div id="charts"></div>
</div>
<div class="col-sm-1"></div>
</div>

<hr>

<div class="table table-striped">
<table id="datatable" class="display" width="100%"></table>
Expand Down
2 changes: 1 addition & 1 deletion code/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</div>

<div class="footer-copyright text-center py-3">
ReDU - Release 11
ReDU - Release 11.1
</div>

<style>
Expand Down
11 changes: 2 additions & 9 deletions code/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,23 +444,16 @@ def compoundenrichment():

for attribute in all_attributes:
filtered_df = enrichment_df[enrichment_df["attribute_name"] == attribute]
filtered_df = filtered_df[filtered_df["percentage"] > 0]

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

all_tabs.append(tab)

# script, div = components(plot)

# draw_dict = {}
# draw_dict["script"] = script
# draw_dict["div"] = div

# drawing_dict[attribute] = draw_dict

tabs = Tabs(tabs=all_tabs)
script, div = components(tabs)

Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions examples/ExtendedDataFigure2/emperor-settings.json

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions test-production-integration/test_selenium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
import unittest, time, re
import os

SERVER_URL = os.environ.get("SERVER_URL", "https://redu.ucsd.edu")

class TestInterfaceready(unittest.TestCase):
def setUp(self):
options = webdriver.ChromeOptions()
options.add_argument('headless')
#self.driver = webdriver.Chrome(options=options)
self.driver = webdriver.PhantomJS()
self.driver.implicitly_wait(30)
self.vars = {}

def tearDown(self):
self.driver.quit()

def test_compound_enrichment(self):
#going to the page
url = "{}/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE".format(SERVER_URL)
print(url)
self.driver.get(url)
time.sleep(1)

wait = WebDriverWait(self.driver, 180)

#waiting for the modal to go aay
wait.until(EC.invisibility_of_element_located((By.ID, 'loadMe')))

#waiting for the button to be clickable
wait.until(EC.element_to_be_clickable((By.ID,'querycompound')))

#clicking the button
python_button = self.driver.find_element(By.ID, 'querycompound')

python_button.click()
#time.sleep(60)

try:
alert = self.driver.switch_to.alert
alert.accept()
print("alert present, error")
return 1
except Exception:
print("no alert, passing")

if __name__ == "__main__":
unittest.main()

0 comments on commit 7136938

Please sign in to comment.