librelist archives

« back to archive

How to send file and JSON in single POST-request with test_client() of Flask-instance?

How to send file and JSON in single POST-request with test_client() of Flask-instance?

From:
NtVisigoth
Date:
2015-07-12 @ 20:35
Hello, Everyone!

I have a trouble with testing.

1.
I received test client :

        self.app = create_app(configName='testing')
        self.app_ctx = self.app.app_context()
        self.app_ctx.push()
        db.create_all()
        self.client = self.app.test_client()

2. Then I want to send a POST-request with file and JSON. Nota bene: file
and json in single request, I want do this action with test_client().

How to write code with for send this request?

self.client.post(url_for('main_blueprint.upload_file', ????? ))

any ideas ?

-- 
In Russian:
С уважением, Дмитрий Андриянков.