From 8602afba72bb2a284dfb45c41649e240d18fa499 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Wed, 8 Jan 2020 17:02:05 -0800 Subject: [PATCH 01/10] adding selenium tests, but is an issue with ajax --- code/templates/compoundenrichment.html | 2 +- test-production-integration/test_selenium.py | 41 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test-production-integration/test_selenium.py diff --git a/code/templates/compoundenrichment.html b/code/templates/compoundenrichment.html index 4e61d0c..46eeb2d 100644 --- a/code/templates/compoundenrichment.html +++ b/code/templates/compoundenrichment.html @@ -106,7 +106,7 @@

Chemical Enrichment Query Interface

methods: { clickMe: querycompound }, - template: '
' + template: '
' }) var app4 = new Vue({ diff --git a/test-production-integration/test_selenium.py b/test-production-integration/test_selenium.py new file mode 100644 index 0000000..f98f1df --- /dev/null +++ b/test-production-integration/test_selenium.py @@ -0,0 +1,41 @@ +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 +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): + self.driver = webdriver.PhantomJS() + self.driver.implicitly_wait(30) + self.vars = {} + + def tearDown(self): + self.driver.quit() + + def test_compound_enrichment(self): + #self.driver.get("{}/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE".format(SERVER_URL)) + self.driver.get("http://localhost:5005/compoundenrichmentdashboard?compound=ESCITALOPRAM%20OXALATE") + time.sleep(1) + WebDriverWait(self.driver, 180).until(expected_conditions.element_to_be_clickable((By.ID, "queryresultsbutton"))) + python_button = self.driver.find_element_by_id("queryresultsbutton") + 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() \ No newline at end of file From 3e971bb252b53c0e2a48d6ba73055caa4cb1f284 Mon Sep 17 00:00:00 2001 From: Mingxun Wang Date: Tue, 24 Mar 2020 13:51:15 -0700 Subject: [PATCH 02/10] resizing visualization --- code/templates/compoundenrichment.html | 12 +++++++++++- code/views.py | 11 ++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/code/templates/compoundenrichment.html b/code/templates/compoundenrichment.html index 2b532bb..a64107f 100644 --- a/code/templates/compoundenrichment.html +++ b/code/templates/compoundenrichment.html @@ -23,7 +23,17 @@

Chemical Enrichment Query Interface

-
+
+ +
+
+
+
+
+
+
+ +
diff --git a/code/views.py b/code/views.py index 507b11b..f31439c 100644 --- a/code/views.py +++ b/code/views.py @@ -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) From 0242e40614bbcc124590cd3793f3f99743acf209 Mon Sep 17 00:00:00 2001 From: Ming Wang Date: Wed, 25 Mar 2020 14:19:18 -0700 Subject: [PATCH 03/10] Update layout.html --- code/templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/templates/layout.html b/code/templates/layout.html index 0831602..500f39f 100644 --- a/code/templates/layout.html +++ b/code/templates/layout.html @@ -80,7 +80,7 @@