lundi 26 septembre 2016

Testing external URLs in Django

I'm currently having a hard time getting some of my Django tests to work. What I'm trying to do is test if a given URL (the REST API I want to consume) is up and running (returning status code 200) and later on if it's responding the expected values. However, all I get returned is a status code 404 (Page not found), even though the URL is definitely the right one. (Tried the exact string in my browser)

This is the code:

from django.test import TestCase


class RestTest(TestCase):
    def test_api_test_endpoint(self):
        response = self.client.get("http://ift.tt/2cQ1Y10")
        self.assertEqual(response.status_code, 200, "Status code not equals 200")

It always returns a 404 instead of a 200... Anyone knows what I do wrong here?

Aucun commentaire:

Enregistrer un commentaire