Beispiel #1
0
def test_serial_interface(mocker):
    name = "dummy_serial"
    register_plugin(name, "serial", "test_plugin:DummySerial")
    mock_xexpect = mocker.patch("roast.serial.Xexpect",
                                return_value=mocker.Mock("xexpect"))
    mock_xexpect.return_value.expect = mocker.Mock("xexpect",
                                                   return_value="xexpect")
    mock_xexpect.return_value.sendline = mocker.Mock("sendline")
    mock_xexpect.return_value.runcmd = mocker.Mock("runcmd")
    mock_xexpect.return_value.runcmd_list = mocker.Mock("runcmd_list")
    mock_xexpect.return_value.sendcontrol = mocker.Mock("sendcontrol")
    mock_xexpect.return_value.send = mocker.Mock("send")
    mock_xexpect.return_value.output = mocker.Mock("output")
    mock_xexpect.return_value._setup_init = mocker.Mock("setup_init")
    mock_xexpect.return_value.search = mocker.Mock("search")
    mock_xexpect.return_value.sync = mocker.Mock("sync")
    s = Serial(serial_type="dummy_serial", config=config)
    assert isinstance(s, Serial)
    assert s.driver.config == config
    assert s.driver.hostname == "hostname"
    assert s.driver.configure == True
    assert s.driver.connect == True
    s.driver.prompt = "prompt"
    assert s.driver.prompt == "prompt"
    s.exit()
    assert s.driver.exit == True
Beispiel #2
0
def test_component_interface(request):
    ts_name = "dummy_ts"
    sys_name = "dummy_sys"
    register_plugin(ts_name, "testsuite", "test_component:DummyTestSuite")
    register_plugin(sys_name, "system", "test_component:DummySystem")

    rootdir = request.config.rootdir.strpath
    fspath = request.node.fspath
    test_name = request.node.name
    config = generate_conf(rootdir, fspath, test_name)
    config["roast.testsuite"] = ts_name
    config["roast.system"] = [sys_name]
    scn = scenario(config)
    scn.configure_component()
    ts = scn.ts
    sys = scn.sys(sys_name)
    assert ts.configured == True
    assert sys.configured == True

    results = scn.build_component()
    assert results[ts_name] == True
    assert results[sys_name] == True

    results = scn.deploy_component()
    assert results[ts_name] == True

    results = scn.run_component()
    assert results[ts_name] == True
Beispiel #3
0
 def __init__(self, relay_type: str, **kwargs) -> None:
     if relay_type is None:
         relay_type = "dummy_relay"
         kwargs = {}
         register_plugin(
             "dummy_relay",
             "relay",
             "roast.component.relay:DummyRelay",
         )
     self._relay_mgr = driver.DriverManager(
         namespace="roast.relay",
         name=relay_type,
         invoke_on_load=True,
         invoke_kwds=kwargs,
     )
Beispiel #4
0
def test_register_plugin():
    location = __file__
    name = "dummy_serial"
    register_plugin(location, name, "serial", "tests.test_plugin:DummyPlugin")
    serial_entries = [
        entry_point.name
        for entry_point in pkg_resources.iter_entry_points("roast.serial")
    ]
    assert name in serial_entries

    name = "dummy_board"
    register_plugin(location, name, "board", "tests.test_plugin:DummyPlugin")
    board_entries = [
        entry_point.name
        for entry_point in pkg_resources.iter_entry_points("roast.board")
    ]
    assert name in board_entries
Beispiel #5
0
def test_register_plugin():
    namespace = "roast.serial"
    name = "dummy_serial"
    register_plugin(name, "serial", "tests.test_plugin:DummySerial")
    e = ExtensionManager(namespace)
    serial_entries = [
        entry_point.name for entry_point in e.ENTRY_POINT_CACHE.get(namespace)
    ]
    assert name in serial_entries

    namespace = "roast.board"
    name = "dummy_board"
    register_plugin(name, "board", "tests.test_plugin:DummyBoard")
    e = ExtensionManager(namespace)
    board_entries = [
        entry_point.name for entry_point in e.ENTRY_POINT_CACHE.get(namespace)
    ]
    assert name in board_entries
Beispiel #6
0
def b():
    name = "dummy_board"
    register_plugin(name, "board", "tests.test_plugin:DummyBoard")
    return Board(board_type=name)
Beispiel #7
0
def test_register_plugin_exception():
    with pytest.raises(Exception, match="not supported"):
        register_plugin("", "", "")
Beispiel #8
0
def s():
    name = "dummy_serial"
    register_plugin(name, "serial", "tests.test_plugin:DummySerial")
    return Serial(serial_type=name, config=config)