Exemplo n.º 1
0
def test_bad_args(monkeypatch, args, mock_server):
    s, SpallocServer = mock_server
    s.is_alive.return_value = False
    import spalloc_server.server
    monkeypatch.setattr(spalloc_server.server, "SpallocServer", SpallocServer)

    with pytest.raises(SystemExit):
        main(args.split())

    assert len(SpallocServer.mock_calls) == 0
Exemplo n.º 2
0
def test_commandline(monkeypatch, config_file, args, cold_start, mock_server):
    s, SpallocServer = mock_server
    s.is_alive.return_value = False
    import spalloc_server.server
    monkeypatch.setattr(spalloc_server.server, "SpallocServer", SpallocServer)

    main(args.format(config_file).split())

    SpallocServer.assert_called_once_with(config_filename=config_file,
                                          cold_start=cold_start, port=22244)
Exemplo n.º 3
0
def test_keyboard_interrupt(monkeypatch, config_file, mock_server):
    s, SpallocServer = mock_server
    import spalloc_server.server
    monkeypatch.setattr(spalloc_server.server, "SpallocServer", SpallocServer)

    s.is_alive.side_effect = KeyboardInterrupt
    main([config_file])

    SpallocServer.assert_called_once_with(config_filename=config_file,
                                          cold_start=False, port=22244)
    s.is_alive.assert_called_once_with()
    s.stop_and_join.assert_called_once_with()
Exemplo n.º 4
0
def test_bad_args(monkeypatch, args):
    server = Mock()
    Server = Mock(return_value=server)
    server.is_alive.return_value = False
    import spalloc_server.server
    monkeypatch.setattr(spalloc_server.server,
                        "Server", Server)

    with pytest.raises(SystemExit):
        main(args.split())

    assert len(Server.mock_calls) == 0
Exemplo n.º 5
0
def test_commandline(monkeypatch, config_file, args, cold_start):
    server = Mock()
    Server = Mock(return_value=server)
    server.is_alive.return_value = False
    import spalloc_server.server
    monkeypatch.setattr(spalloc_server.server,
                        "Server", Server)

    main(args.format(config_file).split())

    Server.assert_called_once_with(config_filename=config_file,
                                   cold_start=cold_start)
Exemplo n.º 6
0
def test_keyboard_interrupt(monkeypatch, config_file):
    s = Mock()
    Server = Mock(return_value=s)
    import spalloc_server.server
    monkeypatch.setattr(spalloc_server.server,
                        "Server", Server)

    s.is_alive.side_effect = KeyboardInterrupt
    main([config_file])

    Server.assert_called_once_with(config_filename=config_file,
                                   cold_start=False)
    s.is_alive.assert_called_once_with()
    s.stop_and_join.assert_called_once_with()