From c2c6ce93b1feecbcc79b4d52cf68823f14e88410 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Fri, 16 Apr 2021 13:39:03 +0200 Subject: #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. --- tests/units/test_0032_big_response.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/units/test_0032_big_response.py (limited to 'tests/units/test_0032_big_response.py') diff --git a/tests/units/test_0032_big_response.py b/tests/units/test_0032_big_response.py new file mode 100644 index 0000000..49dee76 --- /dev/null +++ b/tests/units/test_0032_big_response.py @@ -0,0 +1,26 @@ +import subprocess +import requests +import unittest +import tempfile + +class TestBigResponse(unittest.TestCase): + + def setUp(self): + self.url = 'http://localhost:8888/scopes' + self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} + self.query = tempfile.NamedTemporaryFile() + self.query.write(b'INSERT INTO centros (nombrecentro, identidad, ' + + b'comentarios, directorio) VALUES ' + + b'("Center", 1, "", ""),' * 5000 + + b'("Center", 1, "", "");') + + def test_get(self): + subprocess.run('mysql --default-character-set=utf8 test-db < ' + + self.query.name, shell=True) + returned = requests.get(self.url, headers=self.headers) + subprocess.run('mysql --default-character-set=utf8 test-db ' + '< config/basic_data.sql', shell=True) + self.assertEqual(returned.status_code, 400) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3-18-g5258