From 08788bd3f30c735830dd6281ac9ff52c5640e3e8 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Fri, 19 Aug 2011 12:23:04 +0300 Subject: [PATCH] ppf: Use capitals for SQL statements in test suite. --- ppf/db/tests/test_access_sqlite.py | 171 +++++++++++++++-------------- 1 file changed, 88 insertions(+), 83 deletions(-) diff --git a/ppf/db/tests/test_access_sqlite.py b/ppf/db/tests/test_access_sqlite.py index 721bddf..a3d4f5b 100644 --- a/ppf/db/tests/test_access_sqlite.py +++ b/ppf/db/tests/test_access_sqlite.py @@ -4,125 +4,130 @@ import sqlite3 import access sql_create_script = """ -drop table if exists status_messages; -drop table if exists verbose_messages; -drop table if exists client_sessions; -drop table if exists btclients; -drop table if exists swarms; - -create table swarms( - id integer primary key autoincrement, - torrent text, - filesize integer check(filesize between 0 and 100000000000), - purpose text, - source text); - -create table btclients( - id integer primary key autoincrement, - name text, - language text, - dht integer check(dht between 0 and 1), - streaming integer check(streaming between 0 and 1)); - -create table client_sessions( - id integer primary key autoincrement, - swarm_id integer references swarms(id) on delete cascade on update cascade, - client_id integer references btclients(id) on delete cascade on update cascade, - system_os text, - system_os_version text, - system_ram integer check (system_ram between 0 and 32768), - system_cpu integer check (system_cpu between 100 and 10000), - public_ip text, - public_port integer check (public_port between 1 and 65535), - ds_limit integer check (ds_limit between 0 and 1000000), - us_limit integer check (us_limit between 0 and 1000000), - start_time date); - -create table status_messages ( - cs_id integer references client_sessions(id) on delete cascade on update cascade, - timestamp date, - peer_num integer check (peer_num between 0 and 100000), - dht integer check (dht between 0 and 100000), - download_speed integer check (download_speed between 0 and 1000000), - upload_speed integer check (upload_speed between 0 and 1000000), - download_size integer check(download_size between 0 and 100000000000), - upload_size integer check(upload_size between 0 and 100000000000), - eta integer); +DROP TABLE IF EXISTS status_messages; +DROP TABLE IF EXISTS verbose_messages; +DROP TABLE IF EXISTS client_sessions; +DROP TABLE IF EXISTS btclients; +DROP TABLE IF EXISTS swarms; + +CREATE TABLE swarms( + id INTEGER PRIMARY KEY AUTOINCREMENT, + torrent TEXT, + filesize INTEGER CHECK(filesize BETWEEN 0 AND 100000000000), + purpose TEXT, + source TEXT +); + +CREATE TABLE btclients( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + language TEXT, + dht INTEGER CHECK(dht BETWEEN 0 AND 1), + streaming INTEGER CHECK(streaming BETWEEN 0 AND 1) +); + +CREATE TABLE client_sessions( + id INTEGER PRIMARY KEY AUTOINCREMENT, + swarm_id INTEGER REFERENCES swarms(id) ON DELETE CASCADE ON UPDATE CASCADE, + client_id INTEGER REFERENCES btclients(id) ON DELETE CASCADE ON UPDATE CASCADE, + system_os TEXT, + system_os_version TEXT, + system_ram INTEGER CHECK(system_ram BETWEEN 0 AND 32768), + system_cpu INTEGER CHECK(system_cpu BETWEEN 100 AND 10000), + public_ip TEXT, + public_port INTEGER CHECK(public_port BETWEEN 1 AND 65535), + ds_limit INTEGER CHECK(ds_limit BETWEEN 0 AND 1000000), + us_limit INTEGER CHECK(us_limit BETWEEN 0 AND 1000000), + start_time DATE +); + +CREATE TABLE status_messages( + cs_id INTEGER REFERENCES client_sessions(id) ON DELETE CASCADE ON UPDATE CASCADE, + timestamp DATE, + peer_num INTEGER CHECK(peer_num BETWEEN 0 AND 100000), + dht INTEGER CHECK(dht BETWEEN 0 AND 100000), + download_speed INTEGER CHECK(download_speed BETWEEN 0 AND 1000000), + upload_speed INTEGER CHECK(upload_speed BETWEEN 0 AND 1000000), + download_size INTEGER CHECK(download_size BETWEEN 0 AND 100000000000), + upload_size INTEGER CHECK(upload_size BETWEEN 0 AND 100000000000), + eta INTEGER +); --- --- direction = 0 -> receive (from peer) --- direction = 1 -> send (to peer) --- -create table verbose_messages ( - cs_id integer references client_sessions(id) on delete cascade on update cascade, - timestamp date, - direction integer check(direction between 0 and 1), - peer_ip text, - peer_port integer check(peer_port between 1 and 65535), - message_type integer check (message_type between 0 and 100), - _index integer check (_index between 0 and 100000), - begin integer check (begin between 0 and 10000000), - length integer check (length between 0 and 10000000), - listen_port integer check(listen_port between 0 and 65535)); +CREATE TABLE verbose_messages( + cs_id INTEGER REFERENCES client_sessions(id) ON DELETE CASCADE ON UPDATE CASCADE, + timestamp DATE, + direction INTEGER CHECK(direction BETWEEN 0 AND 1), + peer_ip TEXT, + peer_port INTEGER CHECK(peer_port BETWEEN 1 AND 65535), + message_type INTEGER CHECK(message_type BETWEEN 0 AND 100), + _index INTEGER CHECK(_index BETWEEN 0 AND 100000), + begin INTEGER CHECK(begin BETWEEN 0 AND 10000000), + length integer check(length BETWEEN 0 AND 10000000), + listen_port INTEGER CHECK(listen_port between 0 AND 65535) +); -- insert BitTorrent clients in `btclients` table -insert into btclients(name, language, dht, streaming) - values('Tribler', 'Python', 1, 1); -insert into btclients(name, language, dht, streaming) - values('libtorrent', 'C++', 1, 0); -insert into btclients(name, language, dht, streaming) - values('Vuze', 'Java', 1, 1); -insert into btclients(name, language, dht, streaming) - values('Transmission', 'C', 1, 0); -insert into btclients(name, language, dht, streaming) - values('Aria', 'C', 1, 0); -insert into btclients(name, language, dht, streaming) - values('Mainline', 'Python', 1, 0); +INSERT INTO btclients(name, language, dht, streaming) + VALUES('Tribler', 'Python', 1, 1); +INSERT INTO btclients(name, language, dht, streaming) + VALUES('libtorrent', 'C++', 1, 0); +INSERT INTO btclients(name, language, dht, streaming) + VALUES('Vuze', 'Java', 1, 1); +INSERT INTO btclients(name, language, dht, streaming) + VALUES('Transmission', 'C', 1, 0); +INSERT INTO btclients(name, language, dht, streaming) + VALUES('Aria', 'C', 1, 0); +INSERT INTO btclients(name, language, dht, streaming) + VALUES('Mainline', 'Python', 1, 0); """ sql_init_script = """ -- insert swarms in `swarms` table -insert into swarms(torrent, filesize, purpose, source) - values('DarkKnight', '123000', 'experiment', 'TVTorrents'); -insert into swarms(torrent, filesize, purpose, source) - values('Fedora', '1024', 'experiment', 'local'); +INSERT INTO swarms(torrent, filesize, purpose, source) + VALUES('DarkKnight', '123000', 'experiment', 'TVTorrents'); +INSERT INTO swarms(torrent, filesize, purpose, source) + VALUES('Fedora', '1024', 'experiment', 'local'); -- insert sessions in `client_sessions` table -insert into client_sessions(swarm_id, client_id, system_os, +INSERT INTO client_sessions(swarm_id, client_id, system_os, system_os_version, system_ram, system_cpu, public_ip, public_port, ds_limit, us_limit, start_time) - values ('1', '2', 'Linux', '2.6.26', '512', '1500', + VALUES ('1', '2', 'Linux', '2.6.26', '512', '1500', '141.85.224.205', '50500', '512', '64', '2455125.02409722'); -insert into client_sessions(swarm_id, client_id, system_os, +INSERT INTO client_sessions(swarm_id, client_id, system_os, system_os_version, system_ram, system_cpu, public_ip, public_port, ds_limit, us_limit, start_time) - values('2', '4', 'Linux', '2.6.26', '512', '1500', + VALUES('2', '4', 'Linux', '2.6.26', '512', '1500', '141.85.224.209', '40400', '512', '64', '2455125.03174769'); -- insert messages in `status_messages` table -insert into status_messages(cs_id, timestamp, peer_num, dht, +INSERT INTO status_messages(cs_id, timestamp, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta) - values('1', '2455128.10', '222', '0', '213', '56', '200', + VALUES('1', '2455128.10', '222', '0', '213', '56', '200', '300', '121.324'); -insert into status_messages(cs_id, timestamp, peer_num, dht, +INSERT INTO status_messages(cs_id, timestamp, peer_num, dht, download_speed, upload_speed, download_size, upload_size, eta) - values('2', '2455128.10', '222', '0', '213', '56', '200', + VALUES('2', '2455128.10', '222', '0', '213', '56', '200', '300', '121.324'); -- insert messages in `verbose_messages` table -insert into verbose_messages(cs_id, timestamp, direction, peer_ip, +INSERT INTO verbose_messages(cs_id, timestamp, direction, peer_ip, peer_port, message_type, _index, begin, length, listen_port) - values('1', '2455128.121295811', '0', '127.0.0.1', '1345', + VALUES('1', '2455128.121295811', '0', '127.0.0.1', '1345', '0', '3', '4', '13', '777'); -insert into verbose_messages(cs_id, timestamp, direction, peer_ip, +INSERT INTO verbose_messages(cs_id, timestamp, direction, peer_ip, peer_port, message_type, _index, begin, length, listen_port) - values('2', '2455128.121295811', '1', '127.0.0.1', '1345', + VALUES('2', '2455128.121295811', '1', '127.0.0.1', '1345', '0', '3', '4', '13', '777'); """ -- 2.20.1