source: ogServer-Git/tests/units/test_0032_big_response.py

Last change on this file was c2c6ce9, checked in by OpenGnSys Support Team <soporte-og@…>, 3 years ago

#915 Add large HTTP response test

This commit adds a test for HTTP responses that are too large to fit in
ogServer response buffer.

It also moves the basic sql data used for the other tests to its own
file, easing its reuse in several files.

  • Property mode set to 100644
File size: 1007 bytes
Line 
1import subprocess
2import requests
3import unittest
4import tempfile
5
6class TestBigResponse(unittest.TestCase):
7
8    def setUp(self):
9        self.url = 'http://localhost:8888/scopes'
10        self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
11        self.query = tempfile.NamedTemporaryFile()
12        self.query.write(b'INSERT INTO centros (nombrecentro, identidad, '
13                         + b'comentarios, directorio) VALUES '
14                         + b'("Center", 1, "", ""),' * 5000
15                         + b'("Center", 1, "", "");')
16
17    def test_get(self):
18        subprocess.run('mysql --default-character-set=utf8 test-db < '
19                       + self.query.name, shell=True)
20        returned = requests.get(self.url, headers=self.headers)
21        subprocess.run('mysql --default-character-set=utf8 test-db '
22                       '< config/basic_data.sql', shell=True)
23        self.assertEqual(returned.status_code, 400)
24
25if __name__ == '__main__':
26    unittest.main()
Note: See TracBrowser for help on using the repository browser.