Can the Django client test be used for API calls in production?

I am creating a Django application with a Piston API. To keep everything as dry as possible and the API complete, I would like my internal applications to call the API, not the models (like proxy view-controller a la https://github.com/raganwald/homoiconic/blob/master/ 2010/10 / vc_without_m.md , but all on the same django installation at the moment). So, the basic setup:

Model -> API -> Application -> User Client

I can overload some of the main Piston classes to create an internal client interface for the application, but I wonder if I can just use the Django test client to do the same. Therefore, to create an article, and not to call a model, I will run:

from django.test.client import Client
c = Client()
article = c.post('/api/articles', {
  'title' : 'My Title',
  'content' : 'My Content'
})

, ? (, ) , ?

+3
1

TestClient , . , . Piston DjangoEmitter API.

, .

+6

Source: https://habr.com/ru/post/1783035/


All Articles