You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/04 12:17:56 UTC

[GitHub] [airflow] ashb commented on a change in pull request #15574: #12401 - Duplicating connections from UI

ashb commented on a change in pull request #15574:
URL: https://github.com/apache/airflow/pull/15574#discussion_r625731037



##########
File path: tests/www/test_views.py
##########
@@ -270,6 +270,73 @@ def test_prefill_form_null_extra(self):
         cmv.prefill_form(form=mock_form, pk=1)
 
 
+class TestMultiDuplicateConnectionModelView(TestBase):
+    def setUp(self):
+        super().setUp()
+        conn1 = Connection(
+            conn_id='google_cloud_default',
+            conn_type='Google Cloud',
+            description='Default Google Cloud Connection',
+        )
+
+        # Already copied and modified
+        conn2 = Connection(
+            conn_id='mongodb',
+            conn_type='FTP',
+            description='MongoDB2',
+            host='localhost',
+            schema='airflow',
+            port='5567',
+        )
+
+        conn3 = Connection(
+            conn_id='mysql_connection',
+            conn_type='FTP',
+            description='MongoDB2',
+            host='localhost',
+            schema='airflow',
+            port='3306',
+        )
+
+        conn4 = Connection(
+            conn_id='postgres_connection_Copy(1)',
+            conn_type='FTP',
+            description='Postgres',
+            host='localhost',
+            schema='airflow',
+            port='3306',
+        )
+
+        self.clear_table(Connection)
+        self.session.add_all([conn1, conn2, conn3, conn4])
+        self.session.commit()
+
+    def tearDown(self):
+        self.clear_table(Connection)
+        super().tearDown()
+
+    def test_duplicate_connection(self):
+        """ Test Duplicate multiple connection with suffix"""
+
+        mock_form = mock.Mock()
+        mock_form.data = {"action": "mulduplicate", "rowid": [1, 2, 4]}
+        resp = self.client.post('/connection/action_post', data=mock_form.data, follow_redirects=True)
+
+        expected_result = {
+            'google_cloud_default',
+            'google_cloud_default_Copy(1)',
+            'mongodb',
+            'mongodb_Copy(1)',
+            'mysql_connection',
+            'postgres_connection_Copy(1)',
+            'postgres_connection_Copy(2)',
+        }
+        response = {conn[0].strip() for conn in self.session.query(Connection.conn_id).all()}

Review comment:
       ```suggestion
           response = {conn[0] for conn in self.session.query(Connection.conn_id).all()}
   ```
   
   strip shouldn't be needed.

##########
File path: tests/www/test_views.py
##########
@@ -270,6 +270,73 @@ def test_prefill_form_null_extra(self):
         cmv.prefill_form(form=mock_form, pk=1)
 
 
+class TestMultiDuplicateConnectionModelView(TestBase):

Review comment:
       Please don't create a new test class -- instead add methods to the existing TestConnectionModelView

##########
File path: tests/www/test_views.py
##########
@@ -561,15 +626,15 @@ def test_health(self):
             BaseJob.job_type == 'SchedulerJob',
             BaseJob.state == 'running',
             BaseJob.latest_heartbeat == last_scheduler_heartbeat_for_testing_1,
-        ).delete()
+            ).delete()

Review comment:
       Please avoid making formatting only changes to lines you don't otherwise touch, as it makes the git history messier.




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