john-bodley commented on a change in pull request #9794:
URL: 
https://github.com/apache/incubator-superset/pull/9794#discussion_r441707394



##########
File path: tests/celery_tests.py
##########
@@ -132,34 +134,52 @@ def run_sql(
                 select_as_cta=cta,
                 tmp_table_name=tmp_table,
                 client_id=client_id,
+                cta_method=cta_method,
             ),
         )
         self.logout()
         return json.loads(resp.data)
 
-    def test_run_sync_query_dont_exist(self):
+    @parameterized.expand(
+        [CtaMethod.TABLE,]
+    )
+    def test_run_sync_query_dont_exist(self, cta_method):
         main_db = get_example_database()
         db_id = main_db.id
         sql_dont_exist = "SELECT name FROM table_dont_exist"
-        result1 = self.run_sql(db_id, sql_dont_exist, "1", cta=True)
-        self.assertTrue("error" in result1)
+        result = self.run_sql(
+            db_id, sql_dont_exist, f"1_{cta_method}", cta=True, 
cta_method=cta_method
+        )
+        if get_example_database().backend != "sqlite" and cta_method == 
CtaMethod.VIEW:
+            self.assertEqual(QueryStatus.SUCCESS, result["status"], msg=result)
+        else:
+            self.assertEqual(QueryStatus.FAILED, result["status"], msg=result)
 
-    def test_run_sync_query_cta(self):
+    @parameterized.expand([CtaMethod.TABLE, CtaMethod.VIEW])

Review comment:
       I like this pattern and frequently use it with `pytest` via 
`@pytest.mark.parametrize`. Unrelated to this change I wonder if we should 
consider using `pytest` as opposed to `unittest`. 

##########
File path: tests/celery_tests.py
##########
@@ -132,34 +134,52 @@ def run_sql(
                 select_as_cta=cta,
                 tmp_table_name=tmp_table,
                 client_id=client_id,
+                cta_method=cta_method,
             ),
         )
         self.logout()
         return json.loads(resp.data)
 
-    def test_run_sync_query_dont_exist(self):
+    @parameterized.expand(
+        [CtaMethod.TABLE,]
+    )
+    def test_run_sync_query_dont_exist(self, cta_method):
         main_db = get_example_database()
         db_id = main_db.id
         sql_dont_exist = "SELECT name FROM table_dont_exist"
-        result1 = self.run_sql(db_id, sql_dont_exist, "1", cta=True)
-        self.assertTrue("error" in result1)
+        result = self.run_sql(
+            db_id, sql_dont_exist, f"1_{cta_method}", cta=True, 
cta_method=cta_method
+        )
+        if get_example_database().backend != "sqlite" and cta_method == 
CtaMethod.VIEW:
+            self.assertEqual(QueryStatus.SUCCESS, result["status"], msg=result)
+        else:
+            self.assertEqual(QueryStatus.FAILED, result["status"], msg=result)
 
-    def test_run_sync_query_cta(self):
+    @parameterized.expand([CtaMethod.TABLE, CtaMethod.VIEW])

Review comment:
       I like this pattern and frequently use it with `pytest` via 
`@pytest.mark.parametrize` decorator. Unrelated to this change I wonder if we 
should consider using `pytest` as opposed to `unittest`. 




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to