kawa-kokosowa / msg

A simple, but powerful RESTful messaging library.
MIT License
3 stars 0 forks source link

Add another test and fix small bug with 404 messages #12

Closed adabarx closed 8 years ago

adabarx commented 8 years ago

Add a line in 'config.py' to stop flask from adding a bunch of useless info to the end of 404 messages.

Test 404 errors when trying to list users that don't exist.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+4.4%) to 68.382% when pulling f4f56f825dd1cf02608e3ffa18d34e3a2ddd5558 on testinization into 03226cd26d6b0495b6bbe262e5a92c9c2defa07b on master.

kawa-kokosowa commented 8 years ago

I'll approve this once the default behavior for nonmapped routes are (ex: what happens when you try to access /fakepath/lol). With this information provided, and in any event a default 404 message implemented, I think it'd be good to merge.

adabarx commented 8 years ago

With the current build, accessing a false path produces this:

➜  msgboard git:(testinization) http GET http://localhost:5000/lol/jk
HTTP/1.1 404 NOT FOUND
Content-Length: 233
Content-Type: text/html
Date: Thu, 14 Jul 2016 02:18:41 GMT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.<

Do we want it to pass JSON data as well?

coveralls commented 8 years ago

Coverage Status

Coverage increased (+6.6%) to 70.588% when pulling 29667970d832a23d49fee97318c4006ab30d56ae on testinization into 03226cd26d6b0495b6bbe262e5a92c9c2defa07b on master.

kawa-kokosowa commented 8 years ago

Yeah make the 404 pass a JSON dict. Something like...

{'status': 404, 'message': 'lol'}

adabarx commented 8 years ago

So changing line 38 to api = flask_restful.Api(app, catch_all_404s=True) produces the following result:

HTTP/1.1 404 NOT FOUND
Content-Length: 137
Content-Type: application/json
Date: Fri, 15 Jul 2016 19:00:33 GMT

{
    "message": "The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again."
}

As for a custom 404 message... I just can't figure it out, I've been trying for the last hour and a half 😞

coveralls commented 8 years ago

Coverage Status

Coverage increased (+6.6%) to 70.588% when pulling 71bd5610761e5b5b479b6c8ad79dd2767585c29e on testinization into 03226cd26d6b0495b6bbe262e5a92c9c2defa07b on master.