예제 #1
0
async def test_get_proxy_request(test_client):
    with patch('backend.sessions.Session.make_request',
               new=success_mock_request):
        client = await test_client(_app)
        session = Session(id=1, dc=CREATE_SESSION_DC)
        client.app.sessions[session.id] = session

        proxy_response = await client.get("%s/1/cookie" % BASE_SESSION_URI)
        assert proxy_response.status == 200
        proxy_text = await proxy_response.text()
        assert ujson.loads(proxy_text) == {"sessionId": 1}
예제 #2
0
async def test_delete_session(test_client):
    with patch('backend.queue_producer.AsyncQueueProducer.add_msg_to_queue',
               new=coroutine(lambda a, b, c: None)):
        client = await test_client(_app)
        session = Session(id=1, dc=CREATE_SESSION_DC)
        client.app.sessions[session.id] = session

        delete_response = await client.delete("%s/1" % BASE_SESSION_URI)
        assert delete_response.status == 200
        delete_text = await delete_response.text()
        assert delete_text == "Session 1 closed"
예제 #3
0
async def create_vmmaster_session(request):
    dc = await helpers.get_desired_capabilities(request)
    sessions_keys = list(request.app.sessions.keys())
    last_session_id = sessions_keys[-1] if sessions_keys else 0
    log.warn("Sessions %s, last id %s" %
             (request.app.sessions, last_session_id))
    session = Session(id=int(last_session_id) + 1, dc=dc)
    log.info("New session %s (%s) for %s" %
             (str(session.id), session.name, str(dc)))
    request.app.sessions[session.id] = session
    return session
예제 #4
0
async def test_get_session(test_client):
    with patch('backend.sessions.Session.make_request',
               new=success_mock_request):
        client = await test_client(_app)
        session = Session(id=1, dc=CREATE_SESSION_DC)
        client.app.sessions[session.id] = session

        get_response = await client.get("%s/1" % BASE_SESSION_URI)
        assert get_response.status == 200
        get_text = await get_response.text()
        get_text = ujson.loads(get_text)
        assert ujson.loads(get_text["session"]["dc"]) == CREATE_SESSION_DC
예제 #5
0
async def test_vmmaster_command_request(test_client):
    with patch('backend.sessions.Session.make_request',
               new=success_mock_request):
        client = await test_client(_app)
        session = Session(id=1, dc=CREATE_SESSION_DC)
        client.app.sessions[session.id] = session

        proxy_response = await client.post("%s/vmmasterLabel/session/1" %
                                           BASE_VMMASTER_URI,
                                           data=CREATE_SESSION_DATA)
        assert proxy_response.status == 200
        proxy_text = await proxy_response.text()
        assert proxy_text == "vmmaster command 1"