mirror of https://git.48k.eu/ogserver
#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.master
parent
0b5c0813fa
commit
c2c6ce93b1
|
@ -0,0 +1,41 @@
|
|||
|
||||
DELETE FROM centros;
|
||||
INSERT INTO centros (
|
||||
idcentro, nombrecentro, identidad, comentarios, directorio)
|
||||
VALUES
|
||||
(1, 'Center', 1, '', '');
|
||||
|
||||
DELETE FROM aulas;
|
||||
INSERT INTO aulas (
|
||||
nombreaula, idcentro, urlfoto, grupoid,
|
||||
ubicacion, puestos, modomul, ipmul,
|
||||
pormul, velmul, router, netmask, ntp,
|
||||
dns, proxy, modp2p, timep2p
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'Room', 1, 'aula.jpg', 0, 'Test room.',
|
||||
5, 2, '239.194.2.11', 9000, 70, '192.168.56.1',
|
||||
'255.255.255.0', '', '', '', 'peer',
|
||||
30
|
||||
);
|
||||
|
||||
DELETE FROM ordenadores;
|
||||
INSERT INTO ordenadores (
|
||||
nombreordenador, ip, mac, idaula, idrepositorio,
|
||||
idperfilhard, idmenu, idproautoexec,
|
||||
grupoid, router, mascara, arranque,
|
||||
netiface, netdriver, fotoord
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'pc2', '192.168.2.1', '0800270E6501',
|
||||
1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0',
|
||||
'00unknown', 'eth0', 'generic', 'fotoordenador.gif'
|
||||
),
|
||||
(
|
||||
'pc2', '192.168.2.2', '0800270E6502',
|
||||
1, 1, 0, 0, 0, 0, '192.168.56.1', '255.255.255.0',
|
||||
'00unknown', 'eth0', 'generic', 'fotoordenador.gif'
|
||||
);
|
||||
|
|
@ -14,7 +14,8 @@ def start_mysql():
|
|||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
subprocess.run(['mysqladmin', 'create', 'test-db'])
|
||||
subprocess.run('mysql --default-character-set=utf8 test-db < ../cfg/ogAdmBD.sql', shell=True)
|
||||
subprocess.run(['mysql', '-D', 'test-db', '-e', sql_data])
|
||||
subprocess.run('mysql --default-character-set=utf8 test-db '
|
||||
'< config/basic_data.sql', shell=True)
|
||||
subprocess.run(['mysql', '-D', 'test-db', '-e', sql_create_user])
|
||||
|
||||
def stop_mysql():
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue