Writing some unit tests for my flask application. The endpoint '/' works and returns 200 when I try in postman, however flask_testing gives AssertionError: 404 != 200
I have set up a base config.
class BaseTestCase(TestCase):
def create_app(self):
app = Flask(__name__)
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///:memory:"
app.config['JWT_SECRET_KEY'] = environ['JWT_SECRET_KEY']
db = SQLAlchemy(app)
db.init_app(app)
return app
This is the test.
class FlaskTestCase(BaseTestCase):
def test_root(self):
response = self.client.get('/')
self.assertEquals(response.status_code, 200)
Output from tests
======================================================================
FAIL: test_root (test.server-test.FlaskTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/my_name/path/to/my_project/test/server-test.py", line 13, in test_root
self.assertEquals(response.status_code, 200)
AssertionError: 404 != 200
----------------------------------------------------------------------
Ran 1 test in 0.032s
FAILED (failures=1)