Hi,
As we have been facing many issues with different data-type display in
Query Tool output, Dave suggested to write the feature test for the same.
I have started with some basic set of data-type values and will add more.
Please find the attached initial patch for the same.
Thanks,
Khushboo
diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
new file mode 100644
index 0000000..2400b6d
--- /dev/null
+++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
@@ -0,0 +1,138 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+from selenium.webdriver import ActionChains
+from selenium.common.exceptions import TimeoutException
+from regression.python_test_utils import test_utils
+from regression.feature_utils.base_feature_test import BaseFeatureTest
+import time
+
+
+class PGDataypeFeatureTest(BaseFeatureTest):
+ """
+ This feature test will test the different Postgres
+ data-type output.
+ """
+
+ scenarios = [
+ ("Test checks for PG data-types output", dict())
+ ]
+
+ def before(self):
+ connection = test_utils.get_db_connection(self.server['db'],
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port'])
+ test_utils.drop_database(connection, "acceptance_test_db")
+ test_utils.create_database(self.server, "acceptance_test_db")
+
+ def runTest(self):
+ self.page.wait_for_spinner_to_disappear()
+ self._connects_to_server()
+ self._schema_node_expandable()
+
+ # Check data types
+ self._check_datatype()
+
+ def after(self):
+ time.sleep(1)
+ self.page.remove_server(self.server)
+ connection = test_utils.get_db_connection(self.server['db'],
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port'])
+ test_utils.drop_database(connection, "acceptance_test_db")
+
+ def _connects_to_server(self):
+ self.page.find_by_xpath("//*[@class='aciTreeText' and .='Servers']").click()
+ self.page.driver.find_element_by_link_text("Object").click()
+ ActionChains(self.page.driver) \
+ .move_to_element(self.page.driver.find_element_by_link_text("Create")) \
+ .perform()
+ self.page.find_by_partial_link_text("Server...").click()
+
+ server_config = self.server
+ self.page.fill_input_by_field_name("name", server_config['name'])
+ self.page.find_by_partial_link_text("Connection").click()
+ self.page.fill_input_by_field_name("host", server_config['host'])
+ self.page.fill_input_by_field_name("port", server_config['port'])
+ self.page.fill_input_by_field_name("username", server_config['username'])
+ self.page.fill_input_by_field_name("password", server_config['db_password'])
+ self.page.find_by_xpath("//button[contains(.,'Save')]").click()
+
+ def _schema_node_expandable(self):
+ self.page.toggle_open_tree_item(self.server['name'])
+ self.page.toggle_open_tree_item('Databases')
+ self.page.toggle_open_tree_item('acceptance_test_db')
+ self.page.toggle_open_tree_item('Schemas')
+ self.page.toggle_open_tree_item('public')
+
+ def _check_datatype(self):
+ sample_values = ['-32767', '32767', '-2147483647', '2147483647', '9223372036854775807', '9223372036854775807',
+ '922337203685.4775807', '92203685.477', '922337203685.922337203685', '-92233720368547758.08',
+ "ARRAY[1, 2, 'nan']::float[]"
+ ]
+
+ expected_output = ['-32767', '32767', '-2147483647', '2147483647', '9223372036854775807', '9223372036854775807',
+ '922337203685.4775807', '92203685.477', '922337203685.922337203685', '-92233720368547758.08',
+ "1, 2, 'nan'"
+ ]
+
+ # For every sample data-type value, run the query and check the expected output.
+ # The query tool will open and close for every single value as in case of ARRAY[1, 2, 'nan']::float[],
+ # we didn't get the output in the panel instead just the message.
+ cnt = 0
+ for val in sample_values:
+ self._open_query_tool()
+ self.page.fill_codemirror_area_with("SELECT " + val + ";")
+ time.sleep(1)
+ self.page.find_by_id("btn-flash").click()
+ time.sleep(2)
+
+ try:
+ source_code = self.page.find_by_xpath(
+ "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[2]/span"
+ ).get_attribute('innerHTML')
+
+ self._check_result(
+ source_code,
+ expected_output[cnt]
+ )
+ cnt += 1
+ except TimeoutException:
+ assert False, "{0} does not match with {1}".format(val, expected_output[cnt])
+ self._close_query_tool()
+
+ def _open_query_tool(self):
+ self.page.driver.find_element_by_link_text("Tools").click()
+ self.page.find_by_partial_link_text("Query Tool").click()
+ time.sleep(3)
+ self.page.driver.switch_to.frame(self.page.driver.find_element_by_tag_name('iframe'))
+
+ def _close_query_tool(self):
+ self.page.driver.switch_to_default_content()
+ self.page.click_element(
+ self.page.find_by_xpath("//*[@id='dockerContainer']/div/div[3]/div/div[2]/div[1]")
+ )
+ time.sleep(0.5)
+ self.page.driver.switch_to.frame(self.page.driver.find_element_by_tag_name('iframe'))
+ time.sleep(1)
+ self.page.click_element(self.page.find_by_xpath("//button[contains(.,'Yes')]"))
+ time.sleep(0.5)
+ self.page.driver.switch_to_default_content()
+
+ def _check_result(self, source_code, string_to_find):
+ if source_code.find(string_to_find) == -1:
+ assert False, "{0} does not match with {1}".format(source_code, string_to_find)
+ else:
+ assert True
+
+
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers