예제 #1
0
def test_create_session(api_client, patch_build_session,
                        session_hardware_info):
    response = api_client.post("/sessions",
                               json={
                                   "data": {
                                       "type": "Session",
                                       "attributes": {
                                           "sessionType": "calibrationCheck"
                                       }
                                   }
                               })

    assert response.json() == {
        'data': session_hardware_info,
        'links': {
            'POST': {
                'href': '/sessions/calibrationCheck/commands',
            },
            'GET': {
                'href': '/sessions/calibrationCheck',
            },
            'DELETE': {
                'href': '/sessions/calibrationCheck',
            },
        }
    }
    assert response.status_code == 200
    # Clean up
    get_session_manager().sessions.clear()
예제 #2
0
def test_create_session(api_client,
                        patch_create_session,
                        mock_session_meta,
                        session_response):
    response = api_client.post("/sessions", json={
        "data": {
            "type": "Session",
            "attributes": {
                "sessionType": "null"
            }
        }
    })
    assert response.json() == {
        'data': session_response,
        'links': {
            'commandExecute': {
                'href': f'/sessions/{mock_session_meta.identifier}/commands/execute',  # noqa: E501
            },
            'self': {
                'href': f'/sessions/{mock_session_meta.identifier}',
            },
            'sessions': {
                'href': '/sessions'
            },
            'sessionById': {
                'href': '/sessions/{sessionId}'
            }
        }
    }
    assert response.status_code == 201
    # Clean up
    get_session_manager()._sessions = {}
예제 #3
0
async def session_manager_with_session(loop, patch_create_session):
    manager = get_session_manager()
    session = await manager.add(SessionType.null, SessionMetaData())

    yield manager

    await manager.remove(session.meta.identifier)
예제 #4
0
def session_manager_with_session(mock_cal_session):
    manager = get_session_manager()
    manager.sessions[SessionType.calibration_check] = mock_cal_session

    yield mock_cal_session

    if SessionType.calibration_check in manager.sessions:
        del manager.sessions[SessionType.calibration_check]