You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/17 17:25:06 UTC

[GitHub] [incubator-superset] john-bodley commented on a change in pull request #9794: feat: implement create view as functionality in Sqllab

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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org