MCPcopy Create free account
hub / github.com/dot-agent/nextpy / test_upload_file_without_annotation

Function test_upload_file_without_annotation

tests/test_app.py:802–830  ·  view source on GitHub ↗

Test that an error is thrown when there's no param annotated with xt.UploadFile or List[UploadFile]. Args: state: The state class. tmp_path: Temporary path. token: a Token.

(state, tmp_path, token)

Source from the content-addressed store, hash-verified

800 [FileUploadState, ChildFileUploadState, GrandChildFileUploadState],
801)
802async def test_upload_file_without_annotation(state, tmp_path, token):
803 """Test that an error is thrown when there's no param annotated with xt.UploadFile or List[UploadFile].
804
805 Args:
806 state: The state class.
807 tmp_path: Temporary path.
808 token: a Token.
809 """
810 state._tmp_path = tmp_path
811 # The App state must be the "root" of the state tree
812 app = App(state=state if state is FileUploadState else FileStateBase1)
813
814 state_name = state.get_full_name().partition(".")[2] or state.get_name()
815 request_mock = unittest.mock.Mock()
816 request_mock.headers = {
817 "nextpy-client-token": token,
818 "nextpy-event-handler": f"{state_name}.handle_upload2",
819 }
820 file_mock = unittest.mock.Mock(filename="image1.jpg")
821 fn = upload(app)
822 with pytest.raises(ValueError) as err:
823 await fn(request_mock, [file_mock])
824 assert (
825 err.value.args[0]
826 == f"`{state_name}.handle_upload2` handler should have a parameter annotated as List[xt.UploadFile]"
827 )
828
829 if isinstance(app.state_manager, StateManagerRedis):
830 await app.state_manager.close()
831
832
833@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 6

AppClass · 0.90
uploadFunction · 0.90
fnFunction · 0.85
get_full_nameMethod · 0.80
closeMethod · 0.80
get_nameMethod · 0.45

Tested by

no test coverage detected