diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py b/web/pgadmin/feature_tests/pg_datatype_validation_test.py index 69b12f3..b883aac 100644 --- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py +++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py @@ -53,11 +53,14 @@ class PGDataypeFeatureTest(BaseFeatureTest): 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.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() + .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 @@ -65,8 +68,12 @@ class PGDataypeFeatureTest(BaseFeatureTest): 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.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): @@ -77,15 +84,21 @@ class PGDataypeFeatureTest(BaseFeatureTest): self.page.toggle_open_tree_item('public') def _check_datatype(self): - query = """SELECT -32767::smallint, 32767::smallint, -2147483647::integer, 2147483647::integer, -9223372036854775807::bigint, 9223372036854775807::bigint,922337203685.4775807::decimal, 92203685.477::decimal, -922337203685.922337203685::numeric,-92233720368547758.08::numeric;""" - # TODO :: Currently there is an issue with ARRAY[1, 2, 'nan']::float[] == "1, 2, 'nan'" datatype, - # so ignoring this, will add once the issue will be fixed. - - expected_output = ['-32767', '32767', '-2147483647', '2147483647', '9223372036854775807', '9223372036854775807', - '922337203685.4775807', '92203685.477', '922337203685.922337203685', '-92233720368547758.08' - ] + query = "SELECT -32767::smallint, 32767::smallint," \ + "-2147483647::integer, 2147483647::integer," \ + "9223372036854775807::bigint, 9223372036854775807::bigint," \ + "922337203685.4775807::decimal, 92203685.477::decimal," \ + "922337203685.922337203685::numeric, " \ + "-92233720368547758.08::numeric," \ + "ARRAY[1, 2, 3]::float[], ARRAY['nan', 'nan', 'nan']::float[];" + + expected_output = [ + '-32767', '32767', '-2147483647', '2147483647', + '9223372036854775807', '9223372036854775807', + '922337203685.4775807', '92203685.477', + '922337203685.922337203685', '-92233720368547758.08', + '{1,2,3}', '{NaN,NaN,NaN}' + ] self.page.driver.find_element_by_link_text("Tools").click() self.page.find_by_partial_link_text("Query Tool").click() @@ -94,14 +107,36 @@ class PGDataypeFeatureTest(BaseFeatureTest): self.page.find_by_id("btn-flash").click() wait = WebDriverWait(self.page.driver, 5) wait.until(EC.presence_of_element_located( - (By.XPATH, "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[2]/span"))) + (By.XPATH, "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/" + "div[2]/span"))) # For every sample data-type value, check the expected output. cnt = 2 - for val in expected_output: + for val in expected_output[:10]: + try: + source_code = self.page.find_by_xpath( + "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[" + + str(cnt) + + "]/span" + ).get_attribute('innerHTML') + + PGDataypeFeatureTest.check_result( + source_code, + expected_output[cnt - 2] + ) + cnt += 1 + except TimeoutException: + assert False, "{0} does not match with {1}".format( + val, expected_output[cnt] + ) + + cnt = 12 + for val in expected_output[10:]: try: source_code = self.page.find_by_xpath( - "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[" + str(cnt) + "]/span" + "//*[@id='0']//*[@id='datagrid']/div[5]/div/div/div[" + + str(cnt) + + "]" ).get_attribute('innerHTML') PGDataypeFeatureTest.check_result( @@ -110,12 +145,16 @@ class PGDataypeFeatureTest(BaseFeatureTest): ) cnt += 1 except TimeoutException: - assert False, "{0} does not match with {1}".format(val, expected_output[cnt]) + assert False, "{0} does not match with {1}".format( + val, expected_output[cnt] + ) @staticmethod def check_result(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) + assert False, "{0} does not match with {1}".format( + source_code, string_to_find + ) else: assert True