<commit_before>#!/usr/bin/env python
from __future__ import print_function
from __future__ import unicode_literals
import time
import sys
import os
import pytest
from datetime import datetime
from getpass import getpass
from netmiko import ConnectHandler, FileTransfer
from netmiko import file_transfer

###def test_enable_scp(scp_fixture):
###    ssh_conn, scp_transfer = scp_fixture
###
###    scp_transfer.disable_scp()
###    output = ssh_conn.send_command_expect("show run | inc scp")
###    assert 'ip scp server enable' not in output
###
###    scp_transfer.enable_scp()
###    output = ssh_conn.send_command_expect("show run | inc scp")
###    assert 'ip scp server enable' in output

def test_scp_put(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    if scp_transfer.check_file_exists():
        assert False
    else:
        scp_transfer.put_file()
        assert scp_transfer.check_file_exists() == True

def test_remote_space_available(scp_fixture, expected_responses):
    ssh_conn, scp_transfer = scp_fixture
    remote_space = scp_transfer.remote_space_available()
    assert remote_space >= expected_responses["scp_remote_space"]
    
def test_local_space_available(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    local_space = scp_transfer.local_space_available()
    assert local_space >= 1000000000
    
def test_verify_space_available_put(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    assert scp_transfer.verify_space_available() == True
    # intentional make there not be enough space available
    scp_transfer.file_size = 10000000000
    assert scp_transfer.verify_space_available() == False

def test_remote_file_size(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    if not scp_transfer.check_file_exists():
        scp_transfer.put_file()
    remote_file_size = scp_transfer.remote_file_size()
    assert remote_file_size == 19

def test_md5_methods(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    md5_value = 'd8df36973ff832b564ad84642d07a261'

    remote_md5 = scp_transfer.remote_md5()
    assert remote_md5 == md5_value
    assert scp_transfer.compare_md5() == True

def test_disconnect(scp_fixture):
    """Terminate the SSH session."""
    ssh_conn, scp_transfer = scp_fixture
    ssh_conn.disconnect()

def test_verify_space_available_get(scp_fixture_get):
    ssh_conn, scp_transfer = scp_fixture_get
    assert scp_transfer.verify_space_available() == True
    # intentional make there not be enough space available
    scp_transfer.file_size = 100000000000
    assert scp_transfer.verify_space_available() == False

def test_scp_get(scp_fixture_get):
    ssh_conn, scp_transfer = scp_fixture_get

    if scp_transfer.check_file_exists():
        # File should not already exist
        assert False
    else:
        scp_transfer.get_file()
        if scp_transfer.check_file_exists():
            assert True
        else:
            assert False

def test_md5_methods_get(scp_fixture_get):
    ssh_conn, scp_transfer = scp_fixture_get
    md5_value = 'd8df36973ff832b564ad84642d07a261'
    local_md5 = scp_transfer.file_md5("test9.txt")
    assert local_md5 == md5_value
    assert scp_transfer.compare_md5() == True

def test_disconnect_get(scp_fixture_get):
    """Terminate the SSH session."""
    ssh_conn, scp_transfer = scp_fixture_get
    ssh_conn.disconnect()


def test_file_transfer(scp_file_transfer):
    """Test Netmiko file_transfer function."""
    ssh_conn, file_system = scp_file_transfer
    source_file = 'test9.txt'
    dest_file = 'test9.txt'
    direction = 'put'
    print(file_system)

    transfer_dict = file_transfer(ssh_conn, source_file=source_file,
                                           dest_file=dest_file,<commit_msg>Fixing minor unit tests issue<commit_after>#!/usr/bin/env python
from __future__ import print_function
from __future__ import unicode_literals
import time
import sys
import os
import pytest
from datetime import datetime
from getpass import getpass
from netmiko import ConnectHandler, FileTransfer
from netmiko import file_transfer

###def test_enable_scp(scp_fixture):
###    ssh_conn, scp_transfer = scp_fixture
###
###    scp_transfer.disable_scp()
###    output = ssh_conn.send_command_expect("show run | inc scp")
###    assert 'ip scp server enable' not in output
###
###    scp_transfer.enable_scp()
###    output = ssh_conn.send_command_expect("show run | inc scp")
###    assert 'ip scp server enable' in output

def test_scp_put(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    if scp_transfer.check_file_exists():
        assert False
    else:
        scp_transfer.put_file()
        assert scp_transfer.check_file_exists() == True

def test_remote_space_available(scp_fixture, expected_responses):
    ssh_conn, scp_transfer = scp_fixture
    remote_space = scp_transfer.remote_space_available()
    assert remote_space >= expected_responses["scp_remote_space"]
    
def test_local_space_available(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    local_space = scp_transfer.local_space_available()
    assert local_space >= 1000000000
    
def test_verify_space_available_put(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    assert scp_transfer.verify_space_available() == True
    # intentional make there not be enough space available
    scp_transfer.file_size = 10000000000
    assert scp_transfer.verify_space_available() == False

def test_remote_file_size(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    if not scp_transfer.check_file_exists():
        scp_transfer.put_file()
    remote_file_size = scp_transfer.remote_file_size()
    assert remote_file_size == 18

def test_md5_methods(scp_fixture):
    ssh_conn, scp_transfer = scp_fixture
    md5_value = '679a22fcceef1b6bd3da4944519086b5'

    remote_md5 = scp_transfer.remote_md5()
    assert remote_md5 == md5_value
    assert scp_transfer.compare_md5() == True

def test_disconnect(scp_fixture):
    """Terminate the SSH session."""
    ssh_conn, scp_transfer = scp_fixture
    ssh_conn.disconnect()

def test_verify_space_available_get(scp_fixture_get):
    ssh_conn, scp_transfer = scp_fixture_get
    assert scp_transfer.verify_space_available() == True
    # intentional make there not be enough space available
    scp_transfer.file_size = 100000000000
    assert scp_transfer.verify_space_available() == False

def test_scp_get(scp_fixture_get):
    ssh_conn, scp_transfer = scp_fixture_get

    if scp_transfer.check_file_exists():
        # File should not already exist
        assert False
    else:
        scp_transfer.get_file()
        if scp_transfer.check_file_exists():
            assert True
        else:
            assert False

def test_md5_methods_get(scp_fixture_get):
    ssh_conn, scp_transfer = scp_fixture_get
    md5_value = '679a22fcceef1b6bd3da4944519086b5'
    local_md5 = scp_transfer.file_md5("test9.txt")
    assert local_md5 == md5_value
    assert scp_transfer.compare_md5() == True

def test_disconnect_get(scp_fixture_get):
    """Terminate the SSH session."""
    ssh_conn, scp_transfer = scp_fixture_get
    ssh_conn.disconnect()


def test_file_transfer(scp_file_transfer):
    """Test Netmiko file_transfer function."""
    ssh_conn, file_system = scp_file_transfer
    source_file = 'test9.txt'
    dest_file = 'test9.txt'
    direction = 'put'
    print(file_system)

    transfer_dict = file_transfer(ssh_conn, source_file=source_file,
                                           dest_file=dest_file,
{'fraction_non_alphanumeric': 0.07694355697550585, 'fraction_numerical': 0.02476038338658147, 'mean_word_length': 4.192121630960608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1328948', 'n_tokens_mistral': 2648, 'n_tokens_neox': 2489, 'n_words': 505}