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/02/14 07:43:04 UTC

[GitHub] [airflow] VBhojawala commented on a change in pull request #13859: Added copy connection action

VBhojawala commented on a change in pull request #13859:
URL: https://github.com/apache/airflow/pull/13859#discussion_r575768396



##########
File path: tests/www/test_views.py
##########
@@ -254,6 +254,66 @@ def test_prefill_form_null_extra(self):
         cmv.prefill_form(form=mock_form, pk=1)
 
 
+class TestCopyConnectionModelView(TestBase):
+    def setUp(self):
+        super().setUp()
+        conn1 = Connection(
+            conn_id='aws_mongo',
+            conn_type='FTP',
+            description='MongoDB',
+            host='192.168.55.11',
+            schema='airflow',
+            port='5566',
+        )
+
+        # Already copied and modified
+        conn2 = Connection(
+            conn_id='aws_mongo__1',
+            conn_type='FTP',
+            description='MongoDB2',
+            host='192.168.55.12',
+            schema='airflow',
+            port='5567',
+        )
+
+        conn3 = Connection(
+            conn_id='aws_mysql',
+            conn_type='FTP',
+            description='MongoDB2',
+            host='192.168.55.12',
+            schema='airflow',
+            port='5567',
+        )
+
+        self.clear_table(Connection)
+        self.session.add_all([conn1, conn2, conn3])
+        self.session.commit()
+
+    def tearDown(self):
+        self.clear_table(Connection)
+        super().tearDown()
+
+    def test_copy_connection(self):
+        """ Test copy multiple connection with suffix(already copied )"""
+
+        mock_form = mock.Mock()
+        mock_form.data = {"action": "mulcopy", "rowid": [1, 2, 3]}
+        resp = self.client.post('/connection/action_post', data=mock_form.data, follow_redirects=True)
+
+        expected_result = {
+            'aws_mongo',
+            'aws_mongo__1',
+            'aws_mongo__2',
+            'aws_mongo__3',

Review comment:
       Here in test case i have used '__1' as existing connection to test copy connection which were already copied connection and not renamed after copy.
   
   For Pattern matching in RegEx we have used '__/d+$' to differentiate system(airflow) assigned suffix (we have used same Regex for Task and TaskGroup decorators). User can use  single underscore '_' or '-' to assign number to connection name which will make it start from 1.
   
   For Example 
   
   'mongo_1' -> 'mongo_1__1'
   'mongo-1' -> 'mongo-1__1'




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