Пример #1
0
 def test_create(self, mock_uploaded_control_constructor,
                 mock_upload_file, mock_uploaded_protocol):
     manager = ProtocolManager()
     p = manager.create(mock_upload_file, [])
     mock_uploaded_control_constructor.assert_called_once_with(
         Path(mock_upload_file.filename).stem, mock_upload_file, [])
     assert p == mock_uploaded_protocol
     assert manager._protocols[mock_uploaded_protocol.meta.identifier] == p
Пример #2
0
    def test_create_raises(self,
                           exception,
                           mock_upload_file,
                           mock_uploaded_protocol):
        with patch("robot_server.service.protocol.manager.UploadedProtocol") \
                as mock_construct:
            def raiser(*args, **kwargs):
                raise exception()

            mock_construct.side_effect = raiser

            with pytest.raises(errors.ProtocolIOException):
                manager = ProtocolManager()
                manager.create(mock_upload_file, [])
Пример #3
0
async def create_protocol_file(
    protocol_id: str,
    file: UploadFile = File(...),
    protocol_manager: ProtocolManager = Depends(get_protocol_manager)):
    proto = protocol_manager.get(protocol_id)
    proto.add(file)
    return route_models.ProtocolResponse(data=_to_response(proto))
Пример #4
0
async def delete_protocol(
        protocolId: str,
        protocol_manager: ProtocolManager = Depends(get_protocol_manager)):
    proto = protocol_manager.remove(protocolId)
    return route_models.ProtocolResponse(
        data=_to_response(proto),
        links=get_root_links(router),
    )
Пример #5
0
async def get_protocol(
        protocolId: str,
        protocol_manager: ProtocolManager = Depends(get_protocol_manager)):
    proto = protocol_manager.get(protocolId)
    return route_models.ProtocolResponse(
        data=_to_response(proto),
        links=get_protocol_links(router, proto.meta.identifier)
    )
Пример #6
0
async def create_protocol_file(
        protocolId: str,
        file: UploadFile = File(...),
        protocol_manager: ProtocolManager = Depends(get_protocol_manager)):
    proto = protocol_manager.get(protocolId)
    proto.add(file)
    return route_models.ProtocolResponse(
        data=_to_response(proto),
        links=get_protocol_links(router, proto.meta.identifier),
    )
Пример #7
0
def manager_with_mock_protocol(mock_uploaded_control_constructor,
                               mock_upload_file):
    manager = ProtocolManager()
    manager.create(mock_upload_file, [])
    return manager
Пример #8
0
 def test_get_none(self):
     manager = ProtocolManager()
     assert list(manager.get_all()) == []
Пример #9
0
def get_protocol_manager() -> ProtocolManager:
    """The single protocol manager instance"""
    return ProtocolManager()
Пример #10
0
async def get_protocols(
        protocol_manager: ProtocolManager = Depends(get_protocol_manager)):
    return route_models.MultiProtocolResponse(
        data=[_to_response(u) for u in protocol_manager.get_all()],
        links=get_root_links(router)
    )
Пример #11
0
def session_manager(hardware) -> SessionManager:
    return SessionManager(hardware, ProtocolManager())
Пример #12
0
def session_manager(hardware) -> SessionManager:
    return SessionManager(hardware=hardware,
                          motion_lock=ThreadedAsyncLock(),
                          protocol_manager=ProtocolManager())
Пример #13
0
async def delete_protocol(
    protocol_id: str,
    protocol_manager: ProtocolManager = Depends(get_protocol_manager)):
    proto = protocol_manager.remove(protocol_id)
    return route_models.ProtocolResponse(data=_to_response(proto))