@@ -99,3 +99,48 @@ def test_post_file_route_size_limit() -> None:
9999 os .remove (large_file_name )
100100 assert response .status_code == 413
101101 assert "File is too large" in response .text
102+
103+ def test_post_api_paste_route () -> None :
104+ paste_data = {
105+ "content" : "This is a test paste content" ,
106+ "extension" : "txt"
107+ }
108+ response = client .post ("/api/paste" , json = paste_data )
109+ assert response .status_code == 201
110+ response_json = response .json ()
111+ assert "uuid" in response_json
112+ assert "url" in response_json
113+ assert response_json ["uuid" ].endswith (".txt" )
114+ assert response_json ["url" ].startswith ("http://paste.fosscu.org/paste/" )
115+
116+ # Clean up: delete the created paste
117+ uuid = response_json ["uuid" ]
118+ delete_response = client .delete (f"/paste/{ uuid } " )
119+ assert delete_response .status_code == 200
120+
121+ def test_get_api_paste_route () -> None :
122+ # First, create a paste
123+ paste_data = {
124+ "content" : "This is a test paste content for GET" ,
125+ "extension" : "md"
126+ }
127+ create_response = client .post ("/api/paste" , json = paste_data )
128+ assert create_response .status_code == 201
129+ created_uuid = create_response .json ()["uuid" ]
130+
131+ # Now, test getting the paste
132+ response = client .get (f"/api/paste/{ created_uuid } " )
133+ assert response .status_code == 200
134+ response_json = response .json ()
135+ assert response_json ["uuid" ] == created_uuid
136+ assert response_json ["content" ] == paste_data ["content" ]
137+ assert response_json ["extension" ] == paste_data ["extension" ]
138+
139+ # Clean up: delete the created paste
140+ delete_response = client .delete (f"/paste/{ created_uuid } " )
141+ assert delete_response .status_code == 200
142+
143+ def test_get_api_paste_route_not_found () -> None :
144+ response = client .get ("/api/paste/nonexistent_uuid.txt" )
145+ assert response .status_code == 404
146+ assert response .json ()["detail" ] == "Paste not found"
0 commit comments