public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][Patch][RM2257]: Query tool - Insert row doesn't use default values
Date: Wed, 10 May 2017 19:32:22 +0530
Message-ID: <CAM5-9D8V1-88msMU40ads-Ti6JHKg=S9AvNfNdVn_x_VHFrkVA@mail.gmail.com> (raw)
In-Reply-To: <CAM5-9D9JdEim47AnTVKKhqOBJsbxoO+ufwE7FtPya9HmC6j8Zg@mail.gmail.com>
References: <CAM5-9D_SSL81uT4AqsRr8WPABWA6S-iE34OxLb8YqfVN3myeJg@mail.gmail.com>
	<CA+OCxoySjV87N+YEkhXRzWaaGNCX4o+KuKnVGrYhLuWYeDx+SA@mail.gmail.com>
	<CAM5-9D8MdAqvix74_K+eMkeGkP7r4Aost1Uqz4hupMRPxwqzAw@mail.gmail.com>
	<CA+OCxoxkfbwJaWgCTTZ7eqrkv7Y49jU2EUmDsH_5raZqSFwZsA@mail.gmail.com>
	<CAM5-9D_ZEysH0ewuCoOoon18mim_G9r-2es=+MbyYXnsLqrTEw@mail.gmail.com>
	<CAM5-9D-kZEWrqgxr6-PyB_YVCdovJm8PpXGDpdfcpo65t_Sakg@mail.gmail.com>
	<CA+OCxoyFLFK9nxbpTGJ=f2em1D_fmmFUaxh7LgUeNGWQr3fj6w@mail.gmail.com>
	<CAM5-9D9Pm3bGgiv+fSjfr3Ouc-puMS3m6x4N+vGdELmWVJNcig@mail.gmail.com>
	<CA+OCxozDsoz0NX+4ywBH4gvyHQ2=Lk0f9QT8q2Mj0v=5p+5B_A@mail.gmail.com>
	<CAM5-9D-nWM3i-krc0KbOcAtDQNMefJs+xOFkgP0oaV84wPBbAw@mail.gmail.com>
	<CA+OCxoyNm6zP-=ozL2eTaGpsVgggkp5stU2ZyKhdTzspkAc8sQ@mail.gmail.com>
	<CAM5-9D_76iVD-C+80_7WL1y9skxo5ntmoQbKVOVaMb+0Xa90yg@mail.gmail.com>
	<CA+OCxowq-52VR5hTgBTGa3zGi6NVkAmM2AoGDLW2_wm_QdL0hA@mail.gmail.com>
	<CA+OCxox6_JojQkaujk4qE=egt5Zj6hYe0V33kLYTxQhPMH4H2Q@mail.gmail.com>
	<CAM5-9D8TfBb5YXvEcyd+1=oarWVYOFnN-DVYNx_N3zNRKPGbdg@mail.gmail.com>
	<CA+OCxoxGQfP-HXTfBF+hDLvkex1YDQA+Xovppt6ogT+H8juXGw@mail.gmail.com>
	<CAM5-9D9JdEim47AnTVKKhqOBJsbxoO+ufwE7FtPya9HmC6j8Zg@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi Dave,

Please find attached patch for Feature test cases for RM_2257

*Implementation detail:*

 - Added a test_data.json file which contains Insert and Update test
related input data

 - First of all, we create three tables such as
     a) defaults_text
     b) defaults_boolean
     c) defaults_number
     d) defaults_json
     These tables has columns with different constraints (default value,
not_null etc) to test with various input test data.

- Test cases for insert are executed first and then test cases for update.

Please review the patch.


On Wed, May 10, 2017 at 2:22 PM, Surinder Kumar <
[email protected]> wrote:

> Hi Dave,
>
> Please find attached patch for RM only.
>
> *Changes:*
>
>  - All formatters now handles both [null] and [default] values
>
>  - the cell values are validated on server side as in pgAdmin3.
>
>  - added light grey color for cells with [null] and [default] placeholders.
>
> On Wed, May 10, 2017 at 2:12 PM, Dave Page <[email protected]> wrote:
>
>>
>>
>> On Wed, May 10, 2017 at 9:39 AM, Surinder Kumar <
>> [email protected]> wrote:
>>
>>> Hi Dave,
>>>
>>> On Wed, May 10, 2017 at 2:06 PM, Dave Page <[email protected]> wrote:
>>>
>>>> Any chance we can get this wrapped up today Surinder?
>>>>
>>> ​I have fixed RM case, I am currently writing its feature test cases
>>> which is taking some time.
>>> Should I send patch for RM case only?​ I will try to complete test cases
>>> by today eod.
>>>
>>
>> Yes please.
>>
>> Thanks!
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] features_test_cases_RM_2257_v1.patch (23.3K, 3-features_test_cases_RM_2257_v1.patch)
  download | inline diff:
diff --git a/web/pgadmin/feature_tests/test_data.json b/web/pgadmin/feature_tests/test_data.json
new file mode 100644
index 0000000..672b217
--- /dev/null
+++ b/web/pgadmin/feature_tests/test_data.json
@@ -0,0 +1,88 @@
+{
+  "table_insert_update_cases": {
+
+    "defaults_text": {
+      "insert": {
+        "insert_with_defaults": {
+          "id": "1",
+          "data_default_nulls": "abc123",
+          "data_default_no_nulls": "def456",
+          "data_no_nulls": "test string"
+        }
+      },
+      "update": {
+        "update_with_null_value": {
+          "id": "12",
+          "data_default_nulls": "",
+          "data_nulls": ""
+        },
+        "update_with_empty_string": {
+          "id": "15",
+          "data_default_nulls": "''",
+          "data_nulls": "''"
+        }
+      }
+    },
+    "defaults_boolean": {
+      "insert": {
+        "insert_with_defaults": {
+          "id": "1",
+          "data_default_nulls": "false",
+          "data_default_no_nulls": "false",
+          "data_no_nulls": "true"
+        }
+      },
+      "update": {
+        "update_with_boolean_value": {
+          "id": "12",
+          "data_default_nulls": "true",
+          "data_nulls": "true"
+        }
+      }
+    },
+    "defaults_number": {
+      "insert": {
+        "insert_with_defaults": {
+          "id": "1",
+          "data_default_nulls": "10",
+          "data_default_no_nulls": "20",
+          "data_no_nulls": "10"
+        }
+      },
+      "update": {
+        "update_with_null_value": {
+          "id": "12",
+          "data_default_nulls": "",
+          "data_nulls": ""
+        },
+        "update_with_numeric_value": {
+          "id": "15",
+          "data_default_nulls": "12",
+          "data_nulls": "13"
+        }
+      }
+    },
+    "defaults_json": {
+      "insert": {
+        "insert_with_defaults": {
+          "id": "1",
+          "data_default_nulls": "[0,1]",
+          "data_default_no_nulls": "[2,3]",
+          "data_no_nulls": "[4,5]"
+        }
+      },
+      "update": {
+        "update_with_json_data": {
+          "id": "12",
+          "data_default_nulls": "[10,11,12]",
+          "data_nulls": "[3,4]"
+        },
+        "update_with_null_value": {
+          "id": "15",
+          "data_default_nulls": "",
+          "data_nulls": ""
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/web/pgadmin/feature_tests/view_data_dml_queries.py b/web/pgadmin/feature_tests/view_data_dml_queries.py
new file mode 100644
index 0000000..56d89a4
--- /dev/null
+++ b/web/pgadmin/feature_tests/view_data_dml_queries.py
@@ -0,0 +1,486 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2017, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import json
+import os
+from selenium.webdriver import ActionChains
+from regression.python_test_utils import test_utils
+from regression.feature_utils.base_feature_test import BaseFeatureTest
+import time
+from selenium.webdriver.common.keys import Keys
+from selenium.common.exceptions import NoSuchElementException
+
+
+CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
+
+try:
+    with open(CURRENT_PATH + '/test_data.json') as data_file:
+        config_data = json.load(data_file)['table_insert_update_cases']
+except Exception as e:
+    print(str(e))
+
+
+class CheckForViewDataTest(BaseFeatureTest):
+    """
+    Test cases to validate insert, update operations in table
+    with input test data
+
+    First of all, the test data is inserted/updated into table and then
+    inserted data is compared with original data to check if expected data
+    is returned from table or not.
+
+    We will cover test cases for,
+        1) Insert with default values
+        2) Update with null values
+        3) Update with blank string
+    """
+
+    scenarios = [
+        ("Validate Insert, Update operations in View data with given test "
+         "data",
+         dict())
+    ]
+
+    # To create column id with nextval, first a sequence must be created.
+    create_sequence = """
+CREATE SEQUENCE public.defaults_text_id_seq
+    INCREMENT 1
+    START 9
+    MINVALUE 1
+    MAXVALUE 9223372036854775807
+    CACHE 1;
+
+ALTER SEQUENCE public.defaults_text_id_seq
+    OWNER TO postgres;
+"""
+
+    # query for creating 'defaults_text' table
+    defaults_text_query = """
+CREATE TABLE public.defaults_text
+(
+    id bigint NOT NULL DEFAULT nextval('defaults_text_id_seq'::regclass),
+    data_default_nulls text COLLATE pg_catalog."default" DEFAULT 'abc123'::text,
+    data_default_no_nulls text COLLATE pg_catalog."default" NOT NULL
+DEFAULT 'def456'::text,
+    data_nulls text COLLATE pg_catalog."default",
+    data_no_nulls text COLLATE pg_catalog."default" NOT NULL,
+    CONSTRAINT defaults_text_pkey PRIMARY KEY (id)
+)
+"""
+
+    # query for creating 'defaults_boolean' table
+    defaults_boolean_query = """
+CREATE TABLE public.defaults_boolean
+(
+    id bigint NOT NULL,
+    data_default_nulls boolean DEFAULT false,
+    data_default_no_nulls boolean NOT NULL DEFAULT false,
+    data_nulls boolean,
+    data_no_nulls boolean NOT NULL,
+    CONSTRAINT default_boolean_pkey PRIMARY KEY (id)
+)
+"""
+
+    # query for creating 'defaults_number' table
+    defaults_number_query = """
+CREATE TABLE public.defaults_number
+(
+    id bigint NOT NULL,
+    data_default_nulls numeric(100) DEFAULT 10,
+    data_default_no_nulls numeric(100) NOT NULL DEFAULT 20,
+    data_nulls numeric(100),
+    data_no_nulls numeric(100) NOT NULL,
+    CONSTRAINT default_number_pkey PRIMARY KEY (id)
+)
+"""
+
+    # query for creating 'defaults_json' table
+    defaults_json_query = """
+CREATE TABLE public.defaults_json
+(
+    id bigint NOT NULL,
+    data_default_nulls json DEFAULT '[0,1]'::json,
+    data_default_no_nulls json NOT NULL DEFAULT '[2,3]'::json,
+    data_nulls json,
+    data_no_nulls json NOT NULL,
+    CONSTRAINT defaults_json_pkey PRIMARY KEY (id)
+)
+"""
+
+    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")
+        test_utils.create_table_with_query(
+            self.server,
+            "acceptance_test_db",
+            CheckForViewDataTest.create_sequence)
+
+        # Create pre-requisite tables
+        for key in config_data.keys():
+            test_utils.create_table_with_query(
+                self.server,
+                "acceptance_test_db",
+                getattr(CheckForViewDataTest, key+'_query'))
+
+    def runTest(self):
+        self.page.wait_for_spinner_to_disappear()
+        self._connects_to_server()
+
+        self._tables_node_expandable()
+        for key in config_data.keys():
+            self.driver.switch_to.default_content()
+            self.page.select_tree_item(key)
+            # Open Object -> View data
+            self._check_xss_in_view_data()
+
+            # Run test to insert a new row in table with default values
+            self._insert_row_in_table(key)
+            self._verify_insert_data(key)
+            self._close_query_tool()
+
+        # Run update cells test cases
+        for key in config_data.keys():
+            self.driver.switch_to.default_content()
+            self.page.select_tree_item(key)
+            # Open Object -> View data
+            self._check_xss_in_view_data()
+
+            # Run test to update existing rows in table with given values
+            self._update_row_in_table(key)
+            self._close_query_tool()
+
+    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 _tables_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')
+        self.page.toggle_open_tree_item('Tables')
+
+    def _check_xss_in_view_data(self):
+        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("View Data")) \
+            .perform()
+        self.page.find_by_partial_link_text("View All Rows").click()
+        time.sleep(3)
+        self.page.driver.switch_to.frame(
+            self.page.driver.find_element_by_tag_name('iframe')
+        )
+
+    def _insert_row_in_table(self, table):
+        xpath_cell1 = "//div[contains(@class, 'new-row')]//div[" \
+                     "contains(@class, 'r1')]"
+
+        cell1_val = config_data[table]['insert']['insert_with_defaults'][
+            'id']
+
+        cell2_val = config_data[table]['insert']['insert_with_defaults'][
+            'data_no_nulls']
+
+        time.sleep(1)
+        # Insert into first cell
+        new_row = self.page.find_by_xpath(xpath_cell1)
+        new_row.click()
+        field = new_row.find_element_by_xpath(".//input")
+        field.click()
+        ActionChains(self.driver).send_keys(cell1_val).perform()
+        field.send_keys(Keys.TAB)
+
+        # # Insert into last cell. To insert into cells like boolean,
+        # number, json has different process, so the code is conditional
+        if table == 'defaults_boolean':
+            xpath_cell5 = "//*[@id='datagrid']//div[" \
+                                  "contains(@class, 'new_row')]//div[" \
+                                  "contains(@class, 'r5')]"
+            cell5_el = self.page.find_by_xpath(xpath_cell5)
+            ActionChains(self.driver).move_to_element(cell5_el).double_click(
+                cell5_el
+            ).perform()
+            time.sleep(0.4)
+
+            checkbox_el = cell5_el.find_element_by_xpath(".//input")
+            checkbox_el.click()
+            ActionChains(self.driver).move_to_element(checkbox_el).double_click(
+                checkbox_el
+            ).perform()
+            checkbox_el.send_keys(Keys.TAB)  # Press tab key
+
+        elif table == 'defaults_number':
+            xpath_cell5 = "//*[@id='datagrid']//div[" \
+                          "contains(@class,'new_row')]//div[" \
+                          "contains(@class, 'r5')]"
+            cell5_el = self.page.find_by_xpath(xpath_cell5)
+
+            ActionChains(self.driver).move_to_element(cell5_el).double_click(
+                cell5_el
+            ).perform()
+
+            time.sleep(0.5)
+            cell5_input_el = cell5_el.find_element_by_xpath('.//input')
+            cell5_input_el.click()
+            ActionChains(self.driver).send_keys(cell2_val).perform()
+            cell5_input_el.send_keys(Keys.TAB)  # Press tab key
+        else:
+            xpath_cell5 = "//*[@id='datagrid']//div[contains(@class, " \
+                          "'new_row')]//div[contains(@class, 'r5')]"
+            cell_el = self.page.find_by_xpath(xpath_cell5)
+
+            ActionChains(self.driver).move_to_element(cell_el).double_click(
+                cell_el
+            ).perform()
+
+            cell5_el = self.page.driver.find_element_by_css_selector(
+                "div[style*='z-index: 1000'] textarea"
+            )
+            cell5_el.clear()
+            cell5_el.click()
+            time.sleep(0.5)
+
+            ActionChains(self.driver).send_keys(cell2_val).perform()
+
+            self.page.driver.find_element_by_css_selector(
+                "div[style*='z-index: 1000'] div button:first-child"
+            ).click()  # Click on editor's Save button
+
+        self.page.find_by_id("btn-save").click()  # Save data
+
+    def _verify_insert_data(self, table):
+        time.sleep(0.5)
+        self.page.find_by_id("btn-flash").click()
+        time.sleep(1)
+        main_el = self.page.find_by_xpath('//*[@id="datagrid"]')
+        cell1 = main_el.find_element_by_xpath(
+            './/div[contains(@class, "r1")]//span'
+        ).get_attribute('innerHTML')
+        try:
+            cell2 = main_el.find_element_by_xpath(
+                './/div[contains(@class, "r2")]//span'
+            ).get_attribute('innerHTML')
+        except NoSuchElementException:
+            cell2 = main_el.find_element_by_xpath(
+                './/div[contains(@class, "r2")]'
+            ).get_attribute('innerHTML')
+
+        try:
+            cell3 = main_el.find_element_by_xpath(
+                './/div[contains(@class, "r3")]//span'
+            ).get_attribute('innerHTML')
+        except NoSuchElementException:
+            cell3 = main_el.find_element_by_xpath(
+                './/div[contains(@class, "r3")]'
+            ).get_attribute('innerHTML')
+
+        try:
+            cell5 = main_el.find_element_by_xpath(
+                './/div[contains(@class, "r5")]//span'
+            ).get_attribute('innerHTML')
+        except NoSuchElementException:
+            cell5 = main_el.find_element_by_xpath(
+                './/div[contains(@class, "r5")]'
+            ).get_attribute('innerHTML')
+
+        test_verify_data = config_data[table]['insert'][
+            'insert_with_defaults']
+
+        # compare updated cell values with original values
+        self.assertEquals(cell1, test_verify_data['id'])
+        self.assertEquals(cell2, test_verify_data['data_default_nulls'])
+        self.assertEquals(cell3, test_verify_data['data_default_no_nulls'])
+        self.assertEquals(cell5, test_verify_data['data_no_nulls'])
+
+    def _update_numeric_cell(self, xpath, value):
+        """
+        This function updates the given cell(xpath) with
+        given value
+        Args:
+            xpath: xpath of cell element
+            value: cell value to update
+
+        Returns: None
+
+        """
+        time.sleep(2)
+        cell_el = self.page.find_by_xpath(xpath)
+        ActionChains(self.driver).move_to_element(cell_el).double_click(
+            cell_el
+        ).perform()
+        field = cell_el.find_element_by_xpath(".//input")
+        field.clear()
+        field.click()
+        ActionChains(self.driver).send_keys(value).perform()
+        field.send_keys(Keys.TAB)  # Press tab key
+
+    def _update_text_cell(self, xpath, value):
+        """
+        This function updates the given cell(xpath) with
+        given value
+        Args:
+            xpath: xpath of cell element
+            value: cell value to update
+
+        Returns: None
+
+        """
+        cell_el = self.page.find_by_xpath(xpath)
+        ActionChains(self.driver).move_to_element(cell_el).double_click(
+            cell_el).perform()
+        field = self.page.driver.find_element_by_css_selector(
+            "div[style*='z-index: 1000'] textarea"
+        )
+        field.clear()
+        field.click()
+        time.sleep(1)
+        ActionChains(self.driver).send_keys(value).perform()
+        time.sleep(1)
+        self.page.driver.find_element_by_css_selector(
+            "div[style*='z-index: 1000'] div button:first-child"
+        ).click()  # Click on editor's Save button
+
+    def _update_boolean_cell(self, xpath, value):
+        """
+        This function updates the given cell(xpath) with
+        given value
+        Args:
+            xpath: xpath of cell element
+            value: cell value to update
+
+        Returns: None
+
+        """
+        cell_el = self.page.find_by_xpath(xpath)
+        ActionChains(self.driver).move_to_element(cell_el).double_click(
+            cell_el
+        ).perform()
+        time.sleep(0.4)
+
+        checkbox_el = cell_el.find_element_by_xpath(".//input")
+        checkbox_el.click()
+        ActionChains(self.driver).move_to_element(checkbox_el).double_click(
+            checkbox_el
+        ).perform()
+        checkbox_el.send_keys(Keys.TAB)  # Press tab key
+
+    def _update_row_in_table(self, table):
+        xpath_cell1 = "//div[contains(@class, 'even')]//div[" \
+                        "contains(@class, 'r1')]"
+        xpath_cell2 = "//div[contains(@class, 'even')]//div[" \
+                        "contains(@class, 'r2')]"
+        xpath_cell3 = "//div[contains(@class, 'even')]//div[" \
+                        "contains(@class, 'r4')]"
+
+        update_cases = config_data[table]['update']
+
+        for row in update_cases:
+            cell1 = update_cases[row]['id']
+            cell2 = update_cases[row]['data_default_nulls']
+            cell3 = update_cases[row]['data_nulls']
+
+            if table == 'defaults_boolean':
+                self._update_numeric_cell(xpath_cell1, cell1)
+                self._update_boolean_cell(xpath_cell2, cell2)
+                self._update_boolean_cell(xpath_cell3, cell3)
+            elif table == 'defaults_number':
+                self._update_numeric_cell(xpath_cell1, cell1)
+                self._update_numeric_cell(xpath_cell2, cell2)
+                self._update_numeric_cell(xpath_cell3, cell3)
+            else:
+                self._update_numeric_cell(xpath_cell1, cell1)
+                self._update_text_cell(xpath_cell2, cell2)
+                self._update_text_cell(xpath_cell3, cell3)
+
+            self.page.find_by_id("btn-save").click()  # Save data
+            self._verify_update_data(table, row)
+
+    def _get_cell_value(self, table, xpath):
+        """
+        This function extracts the value from markup and then
+        manipulate if necessary
+        Args:
+            table: test case type [we are using table_name]
+            xpath: xpath for dom element
+
+        Returns: element value
+
+        """
+
+        cell = self.page.find_by_xpath(xpath).get_attribute('innerHTML')
+        if cell.find('<span') != -1:
+            cell = self.page.find_by_xpath(
+                '{0}//span'.format(xpath)
+            ).get_attribute('innerHTML')
+
+        if cell == '[null]':
+            cell = ''
+        else:
+            if table == 'defaults_text':
+                cell = "''" if cell == '' else cell
+        return cell
+
+    def _verify_update_data(self, table, row):
+        time.sleep(0.5)
+        self.page.find_by_id("btn-flash").click()
+        time.sleep(1)
+
+        cell1_xpath = './/div[contains(@class, "r1")]'
+        cell1 = self._get_cell_value(table, cell1_xpath)
+
+        cell2_xpath = './/div[contains(@class, "r2")]'
+        cell2 = self._get_cell_value(table, cell2_xpath)
+
+        cell4_xpath = './/div[contains(@class, "r4")]'
+        cell4 = self._get_cell_value(table, cell4_xpath)
+
+        test_verify_data = config_data[table]['update'][row]
+
+        # compare updated cell values with original values
+        self.assertEquals(cell1, test_verify_data['id'])
+        self.assertEquals(cell2, test_verify_data['data_default_nulls'])
+        self.assertEquals(cell4, test_verify_data['data_nulls'])
+
+    def _close_query_tool(self):
+        time.sleep(0.5)
+        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]")
+        )
\ No newline at end of file
diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py
index f5d0ac7..4bb7d0f 100644
--- a/web/regression/feature_utils/pgadmin_page.py
+++ b/web/regression/feature_utils/pgadmin_page.py
@@ -33,11 +33,11 @@ class PgadminPage:
         self.click_modal_ok()
         self.wait_for_reloading_indicator_to_disappear()
 
-    def click_modal_ok(self):
+    def click_modal_ok(self, btn_label='OK'):
         time.sleep(0.5)
         # Find active alertify dialog in case of multiple alertify dialog & click on that dialog
         self.click_element(
-            self.find_by_xpath("//div[contains(@class, 'alertify') and not(contains(@class, 'ajs-hidden'))]//button[.='OK']")
+            self.find_by_xpath("//*//div[contains(@class, 'alertify') and not(contains(@class, 'ajs-hidden'))]//button[.='{0}']".format(btn_label))
         )
 
     def add_server(self, server_config):
diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py
index 2b7c695..c50dd31 100644
--- a/web/regression/python_test_utils/test_utils.py
+++ b/web/regression/python_test_utils/test_utils.py
@@ -172,6 +172,35 @@ def create_table(server, db_name, table_name):
     except Exception:
         traceback.print_exc(file=sys.stderr)
 
+
+def create_table_with_query(server, db_name, query):
+    """
+    This function create the table in given database name
+    :param server: server details
+    :type server: dict
+    :param db_name: database name
+    :type db_name: str
+    :param query: create table query
+    :type query: str
+    :return: None
+    """
+    try:
+        connection = get_db_connection(db_name,
+                                       server['username'],
+                                       server['db_password'],
+                                       server['host'],
+                                       server['port'])
+        old_isolation_level = connection.isolation_level
+        connection.set_isolation_level(0)
+        pg_cursor = connection.cursor()
+        pg_cursor.execute(query)
+        connection.set_isolation_level(old_isolation_level)
+        connection.commit()
+
+    except Exception:
+        traceback.print_exc(file=sys.stderr)
+
+
 def create_constraint(
         server, db_name, table_name,
         constraint_type="unique", constraint_name="test_unique"):
@@ -274,7 +303,6 @@ def drop_database(connection, database_name):
             connection.commit()
             connection.close()
 
-
 def drop_tablespace(connection):
     """This function used to drop the tablespace"""
     pg_cursor = connection.cursor()


view thread (25+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [pgAdmin4][Patch][RM2257]: Query tool - Insert row doesn't use default values
  In-Reply-To: <CAM5-9D8V1-88msMU40ads-Ti6JHKg=S9AvNfNdVn_x_VHFrkVA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox