potiuk commented on a change in pull request #4938: [AIRFLOW-4117] 
Multi-staging Image - Travis CI tests [Step 3/3]
URL: https://github.com/apache/airflow/pull/4938#discussion_r299567705
 
 

 ##########
 File path: tests/contrib/hooks/test_sftp_hook.py
 ##########
 @@ -25,14 +25,29 @@
 
 from airflow.contrib.hooks.sftp_hook import SFTPHook
 from airflow.models import Connection
+from airflow.utils.db import provide_session
 
 TMP_PATH = '/tmp'
 TMP_DIR_FOR_TESTS = 'tests_sftp_hook_dir'
 TMP_FILE_FOR_TESTS = 'test_file.txt'
 
+SFTP_CONNECTION_USER = "root"
+
 
 class SFTPHookTest(unittest.TestCase):
+
+    @provide_session
+    def update_connection(self, login, session=None):
+        connection = (session.query(Connection).
+                      filter(Connection.conn_id == "sftp_default")
+                      .first())
+        old_login = connection.login
+        connection.login = login
+        session.commit()
+        return old_login
 
 Review comment:
   Again the problem is that I changed the user from airflow to root (reason 
explained below). So i had to change the test to use root user rather than 
airflow - since the sftp server we use in docker is started using the system 
credentials. I figured that using root for the time of test only is a good 
solution. We still have airflow user in the CI image, so I could change it but 
then I would need some extra modifications in the startup scripts. I figured it 
is easier to do it this way. Do you think it is so bad to having to rework it?

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


With regards,
Apache Git Services

Reply via email to