cjsekl commented on a change in pull request #9841:
URL: https://github.com/apache/airflow/pull/9841#discussion_r455896438



##########
File path: tests/providers/postgres/hooks/test_postgres.py
##########
@@ -258,3 +258,16 @@ def 
test_insert_rows_replace_missing_replace_index_arg(self):
                 (2, "world",)]
         fields = ("id", "value")
         self.db_hook.insert_rows(table, rows, fields, replace=True)
+
+    @pytest.mark.backend("postgres")
+    def test_rowcount(self):
+        hook = PostgresHook()
+        input_data = ["foo", "bar", "baz"]
+
+        with hook.get_conn() as conn:
+            with conn.cursor() as cur:
+                cur.execute("CREATE TABLE {} (c VARCHAR)".format(self.table))
+                values = ",".join("('{}')".format(data) for data in input_data)
+                cur.execute("INSERT INTO {} VALUES {}".format(self.table, 
values))
+                conn.commit()
+                self.assertEqual(cur.rowcount, len(input_data))

Review comment:
       Sure thing. Just remind me which log class I need to mock again please?
   I've tried this, but not getting any calls to that `log`.
   
   ```
   class TestDbApiHook(unittest.TestCase):
   
       def setUp(self):
           super().setUp()
   
           self.cur = mock.MagicMock()
           self.conn = mock.MagicMock()
           self.conn.cursor.return_value = self.cur
           conn = self.conn
   
           class UnitTestDbApiHook(DbApiHook):
               conn_name_attr = 'test_conn_id'
               log = mock.MagicMock()
   
               def get_conn(self):
                   return conn
   
           self.db_hook = UnitTestDbApiHook()
   
       def test_run_log(self):
           statement = 'SQL'
           self.db_hook.run(statement)
           assert self.db_hook.log.call_count == 2
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to