mitodl / mit-learn

BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

API Tests should use string urls instead of `reverse()` #448

Closed rhysyngsun closed 7 months ago

rhysyngsun commented 8 months ago

Description/Context

Most of our API tests use django's reverse() function to generate the url for an API. This can be problematic because the tests won't pick up on regressions introduced to the APIs by a change in a urls.py file. Frontend testing might pick up on this but our APIs are increasingly being used outside of this application so verifying that API urls don't change is becoming more critical.

An example of this that we had to fix was the OCW webhook url changing accidentally: https://github.com/mitodl/mit-open/pull/442

habibur4340 commented 8 months ago

Hi @rhysyngsun, Using Django's reverse() for API URL generation in tests hides regressions caused by changes in urls.py. As your APIs are increasingly used externally, ensuring URL stability is crucial. I recommend adding Apidog to your workflow for its direct testing of API endpoints and monitoring features. Apidog can automatically detect changes in URL structures, helping to maintain API consistency and reliability for external consumers.

shanbady commented 7 months ago

A check for api changes has already been implemented. closing