svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

Invalid HTTP response code and No JSON object could be decoded #205

Closed americapires1 closed 8 years ago

americapires1 commented 8 years ago

Hi,

I have installed and run pyresttest Version: 1.7.1 on my macBook Air running Yosemite version 10.10.5. I have followed the instructions on the Quick start part0 guide to check if the server works as follow:

1- I have started the server by cd pyresttest/pyresttest/testapp, then run the command python manage.py testserver test_data.json 2- On another terminal window I run the curl -s http://localhost:8000/api/person/2/ | python -m json.tool

Actual result: - The server starts, however it returns the error 500 as per the log “06/Jul/2016 16:27:40] "GET /api/person/2/ HTTP/1.1" 500 113998” instead of returning the bellow. "{ "first_name": "Leeroy", "id": 2, "last_name": "Jenkins", "login": "jenkins", "resource_uri": "/api/person/2/“ }" 3-On the second terminal where i run curl -s http://localhost:8000/api/person/2/ | python -m json.tool, this returns "No JSON object could be decoded” .

4- Nevertheless, I have created a file called test.yaml and saved it in the second pyresttest folder. The file contain the fallowing:

5-I have cd into the second pyresttest and run the command resttest.py http://localhost:8000 test.yaml Actual result: - I get the following error: "ERROR:Test Failed: Basic smoketest URL=http://localhost:8000/api/person/ Group=Quickstart HTTP Status Code: 500 ERROR:Test Failure, failure type: Invalid HTTP Response Code, Reason: Invalid HTTP response code: response code 500 not in expected codes [[200]]" Test Group Quickstart FAILED: : 0/1 Tests Passed!

NOTE1: I have also run some example test like content-test.yaml and unicode-test.yaml and the outcome is the same Invalid HTTP Response Code error.

NOTE2 - When i paste the server link (http://127.0.0.1:8000/) to a browser, i could see the below error on line 3 of fields.py in the tastypie folder because there isn't any module named dateutil.parser as per below:

ImportError at / No module named dateutil.parser Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.6.11 Exception Type: ImportError Exception Value: No module named dateutil.parser Exception Location: /Library/Python/2.7/site-packages/tastypie/fields.py in , line 3 Python Executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python Python Version: 2.7.11

Could you please advise?

Thanks America

americapires1 commented 8 years ago

I have fixed this.

The problem was because i did not install the project and its packages inside the Virtualenv.

Now, i have done so and its fixed.

Thanks

svanoort commented 8 years ago

It has been known to happen... ;)