예제 #1
0
def test_check_cmd_args():
    """
    Test if config path is correctly checked
    """
    #Config path is correct
    args = ['show','interfaces','ethernet','eth2','description']
    handler = execUtils(list(args))
    assert handler.check_cmd_args() == True
    #Config path not correct
    args = ['show','foo', 'bar']
    with pytest.raises(ConfigPathNotCorrect) as e:
        handler = execUtils(list(args))
        handler.check_cmd_args()
    assert e.value.message == 'Configuration path is not correct'
예제 #2
0
def test_check_cmd_args():
    """
    Test if config path is correctly checked
    """
    #Config path is correct
    args = ['show', 'interfaces', 'ethernet', 'eth2', 'description']
    handler = execUtils(list(args))
    assert handler.check_cmd_args() == True
    #Config path not correct
    args = ['show', 'foo', 'bar']
    with pytest.raises(ConfigPathNotCorrect) as e:
        handler = execUtils(list(args))
        handler.check_cmd_args()
    assert e.value.message == 'Configuration path is not correct'
예제 #3
0
def test_set_iface_desc():
    """
    Test if the description of a giving interface is correctly set.
    """
    args = ['set','interfaces','ethernet','eth2','description','"This is a LAN interface"']
    handler = execUtils(list(args))
    success, out = handler.execmd()
    assert success == True
    session.commit()
    args = ['show','interfaces','ethernet','eth2','description']
    handler = execUtils(list(args))
    success, out = handler.execmd()
    assert args[0] == 'show'
    assert out.split('"')[1] == "This is a LAN interface"
예제 #4
0
def test_execmd_show():
    """
    Test if show command is correctely executed.
    """
    args = ['show','nat','source']
    handler = execUtils(args)
    success, out = handler.execmd()
    assert success == True
예제 #5
0
def test_set_iface_desc():
    """
    Test if the description of a giving interface is correctly set.
    """
    args = [
        'set', 'interfaces', 'ethernet', 'eth2', 'description',
        '"This is a LAN interface"'
    ]
    handler = execUtils(list(args))
    success, out = handler.execmd()
    assert success == True
    session.commit()
    args = ['show', 'interfaces', 'ethernet', 'eth2', 'description']
    handler = execUtils(list(args))
    success, out = handler.execmd()
    assert args[0] == 'show'
    assert out.split('"')[1] == "This is a LAN interface"
예제 #6
0
def test_execmd_show():
    """
    Test if show command is correctely executed.
    """
    args = ['show', 'nat', 'source']
    handler = execUtils(args)
    success, out = handler.execmd()
    assert success == True
예제 #7
0
 def delete(self, args):
     args.insert(0,'delete')
     exe=execUtils(list(args))
     try:
         exe.execmd()
         return True
     except OperationFailed, e:
         logger.error(e.message)
         return False
예제 #8
0
파일: operations.py 프로젝트: ugvddm/pyatta
 def delete(self, args):
     args.insert(0, 'delete')
     exe = execUtils(list(args))
     try:
         exe.execmd()
         return True
     except OperationFailed, e:
         logger.error(e.message)
         return False
예제 #9
0
def test_execmd_missed_args():
    """
    Assert that 'set' command fails because of incomplet args.
    """
    args = ['set']
    with pytest.raises(OperationFailed) as e:
        handler = execUtils(args)
        handler.execmd()
    assert e.value.message == 'Operation failed !'
예제 #10
0
def test_execmd_missed_args():
    """
    Assert that 'set' command fails because of incomplet args.
    """
    args = ['set']
    with pytest.raises(OperationFailed) as e:
        handler = execUtils(args)
        handler.execmd()
    assert e.value.message == 'Operation failed !'
예제 #11
0
def test_show_list_nodes():
    """
    Check if a list of nodes under specified configuration path is correctly returned
    """
    #Config path with more options
    args = ['show','interfaces','ethernet']
    handler = execUtils(list(args))
    success, options = handler.get_possible_options()
    assert success and len(options)
    #Config path without possible options
    args = ['show','interfaces','ethernet','eth2','description']
    handler = execUtils(list(args))
    success, options = handler.get_possible_options()
    assert success and not len(options)
    #Config path is not correct
    args = ['show','foo']
    handler = execUtils(list(args))
    success, options = handler.get_possible_options()
    assert not success and not len(options)
예제 #12
0
def test_show_list_nodes():
    """
    Check if a list of nodes under specified configuration path is correctly returned
    """
    #Config path with more options
    args = ['show', 'interfaces', 'ethernet']
    handler = execUtils(list(args))
    success, options = handler.get_possible_options()
    assert success and len(options)
    #Config path without possible options
    args = ['show', 'interfaces', 'ethernet', 'eth2', 'description']
    handler = execUtils(list(args))
    success, options = handler.get_possible_options()
    assert success and not len(options)
    #Config path is not correct
    args = ['show', 'foo']
    handler = execUtils(list(args))
    success, options = handler.get_possible_options()
    assert not success and not len(options)
예제 #13
0
def test_execmd_out_of_session():
    """
    Assert that config commands are not performed if vyos session is not set up
    """
    #teardown session because it is yet set up by setup_module()
    args = ['show','nat','source']
    session.teardown_config_session()
    #execmd would fail. Otherwise, there is a bug :p
    with pytest.raises(SessionNotExists) as e:
        handler = execUtils(args)
        handler.execmd()
    assert e.value.message == 'Configure session do not exists'
    #resetup session to continue executing remaining tests 
    session.setup_config_session()
예제 #14
0
def test_execmd_out_of_session():
    """
    Assert that config commands are not performed if vyos session is not set up
    """
    #teardown session because it is yet set up by setup_module()
    args = ['show', 'nat', 'source']
    session.teardown_config_session()
    #execmd would fail. Otherwise, there is a bug :p
    with pytest.raises(SessionNotExists) as e:
        handler = execUtils(args)
        handler.execmd()
    assert e.value.message == 'Configure session do not exists'
    #resetup session to continue executing remaining tests
    session.setup_config_session()