def test_cacheinfo_ports_not_initialized(mock_exec):
    mock_exec.return_value = open(
        'tests/test_netshowlib/lspci_output.txt', 'rb').read()

    with mock.patch(mock_open_str()) as mock_open:
        mock_open.side_effect = IOError
        _output = asic.cacheinfo()
        assert_equals(_output,  {'name': 'broadcom', 'asicports': {}, 'kernelports': {}})
Example #2
0
def test_cacheinfo_ports_not_initialized(mock_exec):
    mock_exec.return_value = open('tests/test_netshowlib/lspci_output.txt',
                                  'rb').read()

    with mock.patch(mock_open_str()) as mock_open:
        mock_open.side_effect = IOError
        _output = asic.cacheinfo()
        assert_equals(_output, {
            'name': 'broadcom',
            'asicports': {},
            'kernelports': {}
        })
def test_cacheinfo(mock_exec):
    mock_exec.return_value = io.open(
        'tests/test_netshowlib/lspci_output.txt', 'rb').read()
    values = {
        ('/var/lib/cumulus/porttab',): io.open('tests/test_netshowlib/xe_porttab'),
        ('/etc/bcm.d/config.bcm',): io.open('tests/test_netshowlib/config_xe.bcm')
    }

    with mock.patch('io.open') as mock_open:
        mock_open.side_effect = mod_args_generator(values)
        _output = asic.cacheinfo()
        assert_equals(_output['kernelports']['swp1']['asicname'], 'xe0')
        assert_equals(_output['kernelports']['swp1']['initial_speed'], '10000')
Example #4
0
def test_cacheinfo(mock_exec):
    mock_exec.return_value = io.open('tests/test_netshowlib/lspci_output.txt',
                                     'rb').read()
    values = {
        ('/var/lib/cumulus/porttab', ):
        io.open('tests/test_netshowlib/xe_porttab'),
        ('/etc/bcm.d/config.bcm', ):
        io.open('tests/test_netshowlib/config_xe.bcm')
    }

    with mock.patch('io.open') as mock_open:
        mock_open.side_effect = mod_args_generator(values)
        _output = asic.cacheinfo()
        assert_equals(_output['kernelports']['swp1']['asicname'], 'xe0')
        assert_equals(_output['kernelports']['swp1']['initial_speed'], '10000')
def test_cacheinfo_asic_not_detected(mock_exec):
    mock_exec.side_effect = linux_common.ExecCommandException
    _output = asic.cacheinfo()
    assert_equals(_output,  {'asicports': {}, 'kernelports': {}})