Reputation: 3691
I'm using the django test framwork to test my API. I have a simple view that returns "ok" at the address GET http://localhost:8000/v1/ping/
. When I run the server and I test this with Chrome, it works well. However, when I launch a test on it, I get a 404 error. This is my test:
def test_ping(self):
c = Client()
response = c.get('/v1/ping/')
print response.content
print response.status_code
and the response:
<h1>Not Found</h1><p>The requested URL /v1/ping/ was not found on this server.</p>
404
Upvotes: 1
Views: 1872
Reputation: 3691
I found the error: I use rest_framework_swagger
and there was a test file in it. I deleted it and everything is OK now.
Upvotes: 1
Reputation: 752
The get
method on Django's Test Client takes a relative path as an argument. Have you tried response = c.get('/v1/ping/')
?
Upvotes: 1