def test_sftp_file_with_content_under_python3(self): with self.assertRaises(Exception) as context: cloud.sftp_file("/tmp/test", "ТЕСТ test content") # we successful pass the place with os.write(tmpfd, ... self.assertNotEqual( "a bytes-like object is required, not 'str'", str(context.exception), )
def test_sftp_file_default_alive_args(): server_alive_interval = 60 server_alive_count_max = 3 with patch("salt.utils.cloud.socket", autospec=True), patch( "salt.utils.cloud._exec_ssh_cmd", autospec=True, return_value=0 ) as exec_ssh_cmd: cloud.sftp_file( "/salt.txt", contents=None, kwargs={"hostname": "127.0.0.1", "username": "******"}, local_file="/salt.txt", ) assert exec_ssh_cmd.call_count == 1 ssh_call = exec_ssh_cmd.call_args[0][0] assert "-oServerAliveInterval={}".format(server_alive_interval) in ssh_call assert "-oServerAliveCountMax={}".format(server_alive_count_max) in ssh_call
def test_sftp_file_with_content_under_python3(create_class): with pytest.raises(Exception) as context: cloud.sftp_file("/tmp/test", "ТЕSТ test content") # we successful pass the place with os.write(tmpfd, ... assert "a bytes-like object is required, not 'str'" != str( context.exception)