uranusjr commented on a change in pull request #18161:
URL: https://github.com/apache/airflow/pull/18161#discussion_r724638059
##########
File path: tests/www/views/test_views_connection.py
##########
@@ -148,3 +148,43 @@ def test_duplicate_connection(admin_client):
response = {conn[0] for conn in session.query(Connection.conn_id).all()}
assert resp.status_code == 200
assert expected_result == response
+
+
+def test_duplicate_connection_error(admin_client):
+ """Test Duplicate multiple connection with suffix
+ when there are already 10 copies, no new copy
+ should be created"""
+
+ connections = []
+ connection_ids = []
+
+ for i in range(1, 11):
+ connection_id = f'test_duplicate_postgres_connection_copy{i}'
+ print(f"connection_id {connection_id}")
+ conn1 = Connection(
+ conn_id=connection_id,
+ conn_type='FTP',
+ description='Postgres',
+ host='localhost',
+ schema='airflow',
+ port=3306,
+ )
+ connections.append(conn1)
+ connection_ids.append(conn1.id)
+
+ with create_session() as session:
+ session.query(Connection).delete()
+ session.add_all(connections)
+ session.commit()
+
+ data = {"action": "mulduplicate", "rowid": [conn1.id]}
+ resp = admin_client.post('/connection/action_post', data=data,
follow_redirects=True)
+
+ expected_result = set()
+
+ for i in range(1, 11):
+ expected_result.add(f'test_duplicate_postgres_connection_copy{i}')
Review comment:
```suggestion
expected_result = {f'test_duplicate_postgres_connection_copy{i}' for i
in range(1, 11)}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]