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

Function test_upload_file_background

tests/test_app.py:838–866  ·  view source on GitHub ↗

Test that an error is thrown handler is a background task. Args: state: The state class. tmp_path: Temporary path. token: a Token.

(state, tmp_path, token)

Source from the content-addressed store, hash-verified

836 [FileUploadState, ChildFileUploadState, GrandChildFileUploadState],
837)
838async def test_upload_file_background(state, tmp_path, token):
839 """Test that an error is thrown handler is a background task.
840
841 Args:
842 state: The state class.
843 tmp_path: Temporary path.
844 token: a Token.
845 """
846 state._tmp_path = tmp_path
847 # The App state must be the "root" of the state tree
848 app = App(state=state if state is FileUploadState else FileStateBase1)
849
850 state_name = state.get_full_name().partition(".")[2] or state.get_name()
851 request_mock = unittest.mock.Mock()
852 request_mock.headers = {
853 "nextpy-client-token": token,
854 "nextpy-event-handler": f"{state_name}.bg_upload",
855 }
856 file_mock = unittest.mock.Mock(filename="image1.jpg")
857 fn = upload(app)
858 with pytest.raises(TypeError) as err:
859 await fn(request_mock, [file_mock])
860 assert (
861 err.value.args[0]
862 == f"@xt.background is not supported for upload handler `{state_name}.bg_upload`."
863 )
864
865 if isinstance(app.state_manager, StateManagerRedis):
866 await app.state_manager.close()
867
868
869class DynamicState(BaseState):

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