Пример #1
0
def test_parse_sh_version_return_value():
    """
    Проверка работы функции
    """
    with open("sh_version_r1.txt") as f:
        sh_version_r1 = f.read()
    with open("sh_version_r2.txt") as f:
        sh_version_r2 = f.read()

    correct_return_value_r1 = (
        "12.4(15)T1",
        "flash:c1841-advipservicesk9-mz.124-15.T1.bin",
        "15 days, 8 hours, 32 minutes",
    )
    correct_return_value_r2 = (
        "12.4(4)T",
        "disk0:c7200-js-mz.124-4.T",
        "45 days, 8 hours, 22 minutes",
    )

    return_value_r1 = task_17_2.parse_sh_version(sh_version_r1)
    assert return_value_r1 != None, "Функция ничего не возвращает"
    assert (
        type(return_value_r1) == tuple
    ), f"По заданию функция должна возвращать кортеж, а возвращает {type(return_value_r1).__name__}"
    assert (
        correct_return_value_r1 == return_value_r1
    ), "Функция возвращает неправильное значение для вывода r1"

    return_value_r2 = task_17_2.parse_sh_version(sh_version_r2)
    assert (
        correct_return_value_r2 == return_value_r2
    ), "Функция возвращает неправильное значение для вывода r2"
Пример #2
0
def test_parse_sh_version_return_value():
    """
    Function check
    """
    with open("sh_version_r1.txt") as f:
        sh_version_r1 = f.read()
    with open("sh_version_r2.txt") as f:
        sh_version_r2 = f.read()

    correct_return_value_r1 = (
        "12.4(15)T1",
        "flash:c1841-advipservicesk9-mz.124-15.T1.bin",
        "15 days, 8 hours, 32 minutes",
    )
    correct_return_value_r2 = (
        "12.4(4)T",
        "disk0:c7200-js-mz.124-4.T",
        "45 days, 8 hours, 22 minutes",
    )

    return_value_r1 = task_17_2.parse_sh_version(sh_version_r1)
    assert return_value_r1 != None, "The function returns None"
    assert (
        type(return_value_r1) == tuple
    ), f"The function should return a tuple, instead it returns a {type(return_value_r1).__name__}"
    assert (correct_return_value_r1 == return_value_r1
            ), "Function returns wrong value for r1"
    return_value_r2 = task_17_2.parse_sh_version(sh_version_r2)
    assert (correct_return_value_r2 == return_value_r2
            ), "Function returns wrong value for r2"
Пример #3
0
def test_parse_sh_version_return_value():
    with open('sh_version_r1.txt') as f:
        sh_version_r1 = f.read()
    with open('sh_version_r2.txt') as f:
        sh_version_r2 = f.read()

    correct_return_value_r1 = ('12.4(15)T1',
                               'flash:c1841-advipservicesk9-mz.124-15.T1.bin',
                               '15 days, 8 hours, 32 minutes')
    correct_return_value_r2 = ('12.4(4)T', 'disk0:c7200-js-mz.124-4.T',
                               '45 days, 8 hours, 22 minutes')

    return_value_r1 = task_17_2.parse_sh_version(sh_version_r1)
    assert return_value_r1 != None, "Функция ничего не возвращает"
    assert type(return_value_r1) == tuple, "Функция должна возвращать кортеж"
    assert return_value_r1 == correct_return_value_r1,\
            "Функция возвращает неправильное значение для вывода r1"
    return_value_r2 = task_17_2.parse_sh_version(sh_version_r2)
    assert return_value_r2 == correct_return_value_r2,\
            "Функция возвращает неправильное значение для вывода r2"