summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/config/basic_data.sql41
-rwxr-xr-xtests/run-tests.py3
-rw-r--r--tests/units/test_0032_big_response.py26
3 files changed, 69 insertions, 1 deletions
diff --git a/tests/config/basic_data.sql b/tests/config/basic_data.sql
new file mode 100644
index 0000000..aca246d
--- /dev/null
+++ b/tests/config/basic_data.sql
@@ -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'
+ );
+
diff --git a/tests/run-tests.py b/tests/run-tests.py
index 90a0b2d..f252331 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -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():
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()