diff options
author | Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com> | 2012-10-21 19:21:57 +0200 |
---|---|---|
committer | Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com> | 2012-10-21 19:21:57 +0200 |
commit | 1cdfda58bcc60f5d99de140cf9651e9ee2a660ee (patch) | |
tree | 116dda075b60979b68a4c7f8986b8d48f49522d7 /test | |
parent | 0a6e8d43be72bd0c544bbd401c53d1e8a5615e67 (diff) | |
download | zeitgeist-1cdfda58bcc60f5d99de140cf9651e9ee2a660ee.tar.gz |
More upgrade-test
Diffstat (limited to 'test')
-rw-r--r-- | test/data/databases/071.sql | 2 | ||||
-rw-r--r-- | test/data/databases/080.sql | 279 | ||||
-rw-r--r-- | test/data/databases/090~alpha1.sql | 231 | ||||
-rw-r--r-- | test/data/databases/090~alpha2.sql | 232 | ||||
-rw-r--r-- | test/data/databases/090~alpha3.sql | 237 | ||||
-rw-r--r-- | test/data/upgrade_test.js | 4 | ||||
-rw-r--r-- | test/dbus/upgrade-test.py | 57 |
7 files changed, 1037 insertions, 5 deletions
diff --git a/test/data/databases/071.sql b/test/data/databases/071.sql index 200b5a95..8e982be4 100644 --- a/test/data/databases/071.sql +++ b/test/data/databases/071.sql @@ -16,7 +16,7 @@ INSERT INTO "interpretation" VALUES(6,'stfu:Test'); CREATE TABLE manifestation (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); INSERT INTO "manifestation" VALUES(1,'stfu:YourActivity'); -INSERT INTO "manifestation" VALUES(2,'stfu:File'); +INSERT INTO "manifestation" VALUES(2,'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject'); INSERT INTO "manifestation" VALUES(3,'stfu:BooActivity'); INSERT INTO "manifestation" VALUES(4,'stfu:Ethereal'); INSERT INTO "manifestation" VALUES(5,'stfu:SomeActivity'); diff --git a/test/data/databases/080.sql b/test/data/databases/080.sql new file mode 100644 index 00000000..217bd7fb --- /dev/null +++ b/test/data/databases/080.sql @@ -0,0 +1,279 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE uri + (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); +INSERT INTO "uri" VALUES(1,'file:///tmp'); +INSERT INTO "uri" VALUES(2,'http://www.google.de'); +INSERT INTO "uri" VALUES(3,'belly'); +INSERT INTO "uri" VALUES(5,'file:///tmp/foo.txt'); +INSERT INTO "uri" VALUES(6,'big bang'); +CREATE TABLE interpretation + (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); +INSERT INTO "interpretation" VALUES(1,'stfu:OpenEvent'); +INSERT INTO "interpretation" VALUES(2,'stfu:Document'); +INSERT INTO "interpretation" VALUES(3,'stfu:ShalalalalaEvent'); +INSERT INTO "interpretation" VALUES(4,'stfu:Image'); +INSERT INTO "interpretation" VALUES(5,'stfu:FoobarEvent'); +INSERT INTO "interpretation" VALUES(6,'stfu:Test'); +CREATE TABLE manifestation + (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); +INSERT INTO "manifestation" VALUES(1,'stfu:YourActivity'); +INSERT INTO "manifestation" VALUES(2,'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject'); +INSERT INTO "manifestation" VALUES(3,'stfu:BooActivity'); +INSERT INTO "manifestation" VALUES(4,'stfu:Ethereal'); +INSERT INTO "manifestation" VALUES(5,'stfu:SomeActivity'); +CREATE TABLE mimetype + (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); +INSERT INTO "mimetype" VALUES(1,'meat/raw'); +INSERT INTO "mimetype" VALUES(2,'text/plain'); +CREATE TABLE actor + (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); +INSERT INTO "actor" VALUES(1,'firefox'); +INSERT INTO "actor" VALUES(2,'geany'); +INSERT INTO "actor" VALUES(3,'gedit'); +CREATE TABLE text + (id INTEGER PRIMARY KEY, value VARCHAR UNIQUE); +INSERT INTO "text" VALUES(1,'this item has not text... rly!'); +CREATE TABLE payload + (id INTEGER PRIMARY KEY, value BLOB); +CREATE TABLE storage + (id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE, + state INTEGER, + icon VARCHAR, + display_name VARCHAR); +INSERT INTO "storage" VALUES(1,'net',0,NULL,NULL); +INSERT INTO "storage" VALUES(2,'368c991f-8b59-4018-8130-3ce0ec944157',NULL,NULL,NULL); +CREATE TABLE event ( + id INTEGER, + timestamp INTEGER, + interpretation INTEGER, + manifestation INTEGER, + actor INTEGER, + payload INTEGER, + subj_id INTEGER, + subj_interpretation INTEGER, + subj_manifestation INTEGER, + subj_origin INTEGER, + subj_mimetype INTEGER, + subj_text INTEGER, + subj_storage INTEGER, + origin INTEGER, + subj_id_current INTEGER, + CONSTRAINT interpretation_fk FOREIGN KEY(interpretation) + REFERENCES interpretation(id) ON DELETE CASCADE, + CONSTRAINT manifestation_fk FOREIGN KEY(manifestation) + REFERENCES manifestation(id) ON DELETE CASCADE, + CONSTRAINT actor_fk FOREIGN KEY(actor) + REFERENCES actor(id) ON DELETE CASCADE, + CONSTRAINT origin_fk FOREIGN KEY(origin) + REFERENCES uri(id) ON DELETE CASCADE, + CONSTRAINT payload_fk FOREIGN KEY(payload) + REFERENCES payload(id) ON DELETE CASCADE, + CONSTRAINT subj_id_fk FOREIGN KEY(subj_id) + REFERENCES uri(id) ON DELETE CASCADE, + CONSTRAINT subj_id_current_fk FOREIGN KEY(subj_id_current) + REFERENCES uri(id) ON DELETE CASCADE, + CONSTRAINT subj_interpretation_fk FOREIGN KEY(subj_interpretation) + REFERENCES interpretation(id) ON DELETE CASCADE, + CONSTRAINT subj_manifestation_fk FOREIGN KEY(subj_manifestation) + REFERENCES manifestation(id) ON DELETE CASCADE, + CONSTRAINT subj_origin_fk FOREIGN KEY(subj_origin) + REFERENCES uri(id) ON DELETE CASCADE, + CONSTRAINT subj_mimetype_fk FOREIGN KEY(subj_mimetype) + REFERENCES mimetype(id) ON DELETE CASCADE, + CONSTRAINT subj_text_fk FOREIGN KEY(subj_text) + REFERENCES text(id) ON DELETE CASCADE, + CONSTRAINT subj_storage_fk FOREIGN KEY(subj_storage) + REFERENCES storage(id) ON DELETE CASCADE, + CONSTRAINT unique_event UNIQUE (timestamp, interpretation, manifestation, actor, subj_id) + ); +INSERT INTO "event" VALUES(1,1347652042579,1,1,1,'',2,2,2,1,1,1,2,NULL,2); +INSERT INTO "event" VALUES(2,143,3,3,2,'',5,4,4,1,2,1,2,3,5); +INSERT INTO "event" VALUES(3,133,5,5,3,'',2,6,2,1,2,1,2,6,2); +CREATE TABLE schema_version + (schema VARCHAR PRIMARY KEY ON CONFLICT REPLACE, version INT); +INSERT INTO "schema_version" VALUES('core',4); +CREATE UNIQUE INDEX uri_value ON uri(value); +CREATE UNIQUE INDEX interpretation_value + ON interpretation(value); +CREATE UNIQUE INDEX manifestation_value + ON manifestation(value); +CREATE UNIQUE INDEX mimetype_value + ON mimetype(value); +CREATE UNIQUE INDEX actor_value + ON actor(value); +CREATE UNIQUE INDEX text_value + ON text(value); +CREATE UNIQUE INDEX storage_value + ON storage(value); +CREATE INDEX event_id + ON event(id); +CREATE INDEX event_timestamp + ON event(timestamp); +CREATE INDEX event_interpretation + ON event(interpretation); +CREATE INDEX event_manifestation + ON event(manifestation); +CREATE INDEX event_actor + ON event(actor); +CREATE INDEX event_origin + ON event(origin); +CREATE INDEX event_subj_id + ON event(subj_id); +CREATE INDEX event_subj_id_current + ON event(subj_id_current); +CREATE INDEX event_subj_interpretation + ON event(subj_interpretation); +CREATE INDEX event_subj_manifestation + ON event(subj_manifestation); +CREATE INDEX event_subj_origin + ON event(subj_origin); +CREATE INDEX event_subj_mimetype + ON event(subj_mimetype); +CREATE INDEX event_subj_text + ON event(subj_text); +CREATE INDEX event_subj_storage + ON event(subj_storage); +CREATE TRIGGER fkdc_event_interpretation + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE interpretation=OLD.interpretation) < 2) + BEGIN + DELETE FROM interpretation WHERE id=OLD.interpretation; + END; +CREATE TRIGGER fkdc_event_subj_interpretation + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE subj_interpretation=OLD.subj_interpretation) < 2) + BEGIN + DELETE FROM interpretation WHERE id=OLD.subj_interpretation; + END; +CREATE TRIGGER fkdc_event_manifestation + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE manifestation=OLD.manifestation) < 2) + BEGIN + DELETE FROM manifestation WHERE id=OLD.manifestation; + END; +CREATE TRIGGER fkdc_event_subj_manifestation + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE subj_manifestation=OLD.subj_manifestation) < 2) + BEGIN + DELETE FROM manifestation WHERE id=OLD.subj_manifestation; + END; +CREATE TRIGGER fkdc_event_actor + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE actor=OLD.actor) < 2) + BEGIN + DELETE FROM actor WHERE id=OLD.actor; + END; +CREATE TRIGGER fkdc_event_payload + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE payload=OLD.payload) < 2) + BEGIN + DELETE FROM payload WHERE id=OLD.payload; + END; +CREATE TRIGGER fkdc_event_subj_mimetype + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE subj_mimetype=OLD.subj_mimetype) < 2) + BEGIN + DELETE FROM mimetype WHERE id=OLD.subj_mimetype; + END; +CREATE TRIGGER fkdc_event_subj_text + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE subj_text=OLD.subj_text) < 2) + BEGIN + DELETE FROM text WHERE id=OLD.subj_text; + END; +CREATE TRIGGER fkdc_event_subj_storage + BEFORE DELETE ON event + WHEN ((SELECT COUNT(*) FROM event WHERE subj_storage=OLD.subj_storage) < 2) + BEGIN + DELETE FROM storage WHERE id=OLD.subj_storage; + END; +CREATE TRIGGER fkdc_event_uri_1 + BEFORE DELETE ON event + WHEN (( + SELECT COUNT(*) + FROM event + WHERE + origin=OLD.subj_id + OR subj_id=OLD.subj_id + OR subj_id_current=OLD.subj_id + OR subj_origin=OLD.subj_id + ) < 2) + BEGIN + DELETE FROM uri WHERE id=OLD.subj_id; + END; +CREATE TRIGGER fkdc_event_uri_2 + BEFORE DELETE ON event + WHEN (( + SELECT COUNT(*) + FROM event + WHERE + origin=OLD.subj_origin + OR subj_id=OLD.subj_origin + OR subj_id_current=OLD.subj_origin + OR subj_origin=OLD.subj_origin + ) < 2) + BEGIN + DELETE FROM uri WHERE id=OLD.subj_origin; + END; +CREATE TRIGGER fkdc_event_uri_3 + BEFORE DELETE ON event + WHEN (( + SELECT COUNT(*) + FROM event + WHERE + origin=OLD.subj_id_current + OR subj_id=OLD.subj_id_current + OR subj_id_current=OLD.subj_id_current + OR subj_origin=OLD.subj_id_current + ) < 2) + BEGIN + DELETE FROM uri WHERE id=OLD.subj_id_current; + END; +CREATE TRIGGER fkdc_event_uri_4 + BEFORE DELETE ON event + WHEN (( + SELECT COUNT(*) + FROM event + WHERE + origin=OLD.origin + OR subj_id=OLD.origin + OR subj_id_current=OLD.origin + OR subj_origin=OLD.origin + ) < 2) + BEGIN + DELETE FROM uri WHERE id=OLD.origin; + END; +CREATE VIEW event_view AS + SELECT event.id, + event.timestamp, + event.interpretation, + event.manifestation, + event.actor, + (SELECT value FROM payload WHERE payload.id=event.payload) + AS payload, + (SELECT value FROM uri WHERE uri.id=event.subj_id) + AS subj_uri, + event.subj_id, -- #this directly points to an id in the uri table + event.subj_interpretation, + event.subj_manifestation, + event.subj_origin, + (SELECT value FROM uri WHERE uri.id=event.subj_origin) + AS subj_origin_uri, + event.subj_mimetype, + (SELECT value FROM text WHERE text.id = event.subj_text) + AS subj_text, + (SELECT value FROM storage + WHERE storage.id=event.subj_storage) AS subj_storage, + (SELECT state FROM storage + WHERE storage.id=event.subj_storage) AS subj_storage_state, + event.origin, + (SELECT value FROM uri WHERE uri.id=event.origin) + AS event_origin_uri, + (SELECT value FROM uri WHERE uri.id=event.subj_id_current) + AS subj_current_uri, + event.subj_id_current + FROM event +; +COMMIT; diff --git a/test/data/databases/090~alpha1.sql b/test/data/databases/090~alpha1.sql new file mode 100644 index 00000000..e7508fd3 --- /dev/null +++ b/test/data/databases/090~alpha1.sql @@ -0,0 +1,231 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE uri ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "uri" VALUES(1,'file:///tmp'); +INSERT INTO "uri" VALUES(2,'http://www.google.de'); +INSERT INTO "uri" VALUES(3,'belly'); +INSERT INTO "uri" VALUES(5,'file:///tmp/foo.txt'); +INSERT INTO "uri" VALUES(6,'big bang'); +CREATE TABLE interpretation ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "interpretation" VALUES(1,'stfu:OpenEvent'); +INSERT INTO "interpretation" VALUES(2,'stfu:Document'); +INSERT INTO "interpretation" VALUES(3,'stfu:ShalalalalaEvent'); +INSERT INTO "interpretation" VALUES(4,'stfu:Image'); +INSERT INTO "interpretation" VALUES(5,'stfu:FoobarEvent'); +INSERT INTO "interpretation" VALUES(6,'stfu:Test'); +CREATE TABLE manifestation ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "manifestation" VALUES(1,'stfu:YourActivity'); +INSERT INTO "manifestation" VALUES(2,'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject'); +INSERT INTO "manifestation" VALUES(3,'stfu:BooActivity'); +INSERT INTO "manifestation" VALUES(4,'stfu:Ethereal'); +INSERT INTO "manifestation" VALUES(5,'stfu:SomeActivity'); +CREATE TABLE mimetype ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "mimetype" VALUES(1,'meat/raw'); +INSERT INTO "mimetype" VALUES(2,'text/plain'); +CREATE TABLE actor ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "actor" VALUES(1,'firefox'); +INSERT INTO "actor" VALUES(2,'geany'); +INSERT INTO "actor" VALUES(3,'gedit'); +CREATE TABLE text ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "text" VALUES(1,'this item has not text... rly!'); +CREATE TABLE payload + (id INTEGER PRIMARY KEY, value BLOB); +CREATE TABLE storage ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE, + state INTEGER, + icon VARCHAR, + display_name VARCHAR + ); +INSERT INTO "storage" VALUES(1,'368c991f-8b59-4018-8130-3ce0ec944157',NULL,NULL,NULL); +CREATE TABLE event ( + id INTEGER, + timestamp INTEGER, + interpretation INTEGER, + manifestation INTEGER, + actor INTEGER, + payload INTEGER, + subj_id INTEGER, + subj_interpretation INTEGER, + subj_manifestation INTEGER, + subj_origin INTEGER, + subj_mimetype INTEGER, + subj_text INTEGER, + subj_storage INTEGER, + origin INTEGER, + subj_id_current INTEGER, + CONSTRAINT interpretation_fk + FOREIGN KEY(interpretation) + REFERENCES interpretation(id) + ON DELETE CASCADE, + CONSTRAINT manifestation_fk + FOREIGN KEY(manifestation) + REFERENCES manifestation(id) + ON DELETE CASCADE, + CONSTRAINT actor_fk + FOREIGN KEY(actor) + REFERENCES actor(id) + ON DELETE CASCADE, + CONSTRAINT origin_fk + FOREIGN KEY(origin) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT payload_fk + FOREIGN KEY(payload) + REFERENCES payload(id) + ON DELETE CASCADE, + CONSTRAINT subj_id_fk + FOREIGN KEY(subj_id) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_id_current_fk + FOREIGN KEY(subj_id_current) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_interpretation_fk + FOREIGN KEY(subj_interpretation) + REFERENCES interpretation(id) + ON DELETE CASCADE, + CONSTRAINT subj_manifestation_fk + FOREIGN KEY(subj_manifestation) + REFERENCES manifestation(id) + ON DELETE CASCADE, + CONSTRAINT subj_origin_fk + FOREIGN KEY(subj_origin) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_mimetype_fk + FOREIGN KEY(subj_mimetype) + REFERENCES mimetype(id) + ON DELETE CASCADE, + CONSTRAINT subj_text_fk + FOREIGN KEY(subj_text) + REFERENCES text(id) + ON DELETE CASCADE, + CONSTRAINT subj_storage_fk + FOREIGN KEY(subj_storage) + REFERENCES storage(id) + ON DELETE CASCADE, + CONSTRAINT unique_event UNIQUE (timestamp, interpretation, + manifestation, actor, subj_id) + ); +INSERT INTO "event" VALUES(1,1347652042579,1,1,1,0,2,2,2,1,1,1,1,NULL,2); +INSERT INTO "event" VALUES(2,143,3,3,2,0,5,4,4,1,2,1,1,3,5); +INSERT INTO "event" VALUES(3,133,5,5,3,0,2,6,2,1,2,1,1,6,2); +CREATE TABLE extensions_conf ( + extension VARCHAR, + key VARCHAR, + value BLOB, + CONSTRAINT unique_extension UNIQUE (extension, key) + ); +CREATE TABLE schema_version ( + schema VARCHAR PRIMARY KEY ON CONFLICT REPLACE, + version INT + ); +INSERT INTO "schema_version" VALUES('core',5); +CREATE UNIQUE INDEX uri_value ON uri(value); +CREATE UNIQUE INDEX interpretation_value + ON interpretation(value); +CREATE UNIQUE INDEX manifestation_value + ON manifestation(value); +CREATE UNIQUE INDEX mimetype_value + ON mimetype(value); +CREATE UNIQUE INDEX actor_value + ON actor(value); +CREATE UNIQUE INDEX text_value + ON text(value); +CREATE UNIQUE INDEX storage_value + ON storage(value); +CREATE INDEX event_id + ON event(id); +CREATE INDEX event_timestamp + ON event(timestamp); +CREATE INDEX event_interpretation + ON event(interpretation); +CREATE INDEX event_manifestation + ON event(manifestation); +CREATE INDEX event_actor + ON event(actor); +CREATE INDEX event_origin + ON event(origin); +CREATE INDEX event_subj_id + ON event(subj_id); +CREATE INDEX event_subj_id_current + ON event(subj_id_current); +CREATE INDEX event_subj_interpretation + ON event(subj_interpretation); +CREATE INDEX event_subj_manifestation + ON event(subj_manifestation); +CREATE INDEX event_subj_origin + ON event(subj_origin); +CREATE INDEX event_subj_mimetype + ON event(subj_mimetype); +CREATE INDEX event_subj_text + ON event(subj_text); +CREATE INDEX event_subj_storage + ON event(subj_storage); +CREATE UNIQUE INDEX extensions_conf_key + ON extensions_conf (extension, key); +CREATE VIEW event_view AS + SELECT event.id, + event.timestamp, + event.interpretation, + event.manifestation, + event.actor, + (SELECT value FROM payload + WHERE payload.id=event.payload) + AS payload, + (SELECT value FROM uri + WHERE uri.id=event.subj_id) + AS subj_uri, + event.subj_id, --//this points to an id in the uri table + event.subj_interpretation, + event.subj_manifestation, + event.subj_origin, + (SELECT value FROM uri + WHERE uri.id=event.subj_origin) + AS subj_origin_uri, + event.subj_mimetype, + (SELECT value FROM text + WHERE text.id = event.subj_text) + AS subj_text, + (SELECT value FROM storage + WHERE storage.id=event.subj_storage) + AS subj_storage, + (SELECT state FROM storage + WHERE storage.id=event.subj_storage) + AS subj_storage_state, + event.origin, + (SELECT value FROM uri + WHERE uri.id=event.origin) + AS event_origin_uri, + (SELECT value FROM uri + WHERE uri.id=event.subj_id_current) + AS subj_current_uri, + event.subj_id_current, + event.subj_text AS subj_text_id, + event.subj_storage AS subj_storage_id, + (SELECT value FROM actor + WHERE actor.id=event.actor) + AS actor_uri + FROM event +; +COMMIT; diff --git a/test/data/databases/090~alpha2.sql b/test/data/databases/090~alpha2.sql new file mode 100644 index 00000000..7c67e4f1 --- /dev/null +++ b/test/data/databases/090~alpha2.sql @@ -0,0 +1,232 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE uri ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "uri" VALUES(1,'file:///tmp'); +INSERT INTO "uri" VALUES(2,'http://www.google.de'); +INSERT INTO "uri" VALUES(3,'belly'); +INSERT INTO "uri" VALUES(5,'file:///tmp/foo.txt'); +INSERT INTO "uri" VALUES(6,'big bang'); +CREATE TABLE interpretation ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "interpretation" VALUES(1,'stfu:OpenEvent'); +INSERT INTO "interpretation" VALUES(2,'stfu:Document'); +INSERT INTO "interpretation" VALUES(3,'stfu:ShalalalalaEvent'); +INSERT INTO "interpretation" VALUES(4,'stfu:Image'); +INSERT INTO "interpretation" VALUES(5,'stfu:FoobarEvent'); +INSERT INTO "interpretation" VALUES(6,'stfu:Test'); +CREATE TABLE manifestation ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "manifestation" VALUES(1,'stfu:YourActivity'); +INSERT INTO "manifestation" VALUES(2,'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject'); +INSERT INTO "manifestation" VALUES(3,'stfu:BooActivity'); +INSERT INTO "manifestation" VALUES(4,'stfu:Ethereal'); +INSERT INTO "manifestation" VALUES(5,'stfu:SomeActivity'); +CREATE TABLE mimetype ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "mimetype" VALUES(1,'meat/raw'); +INSERT INTO "mimetype" VALUES(2,'text/plain'); +CREATE TABLE actor ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "actor" VALUES(1,'firefox'); +INSERT INTO "actor" VALUES(2,'geany'); +INSERT INTO "actor" VALUES(3,'gedit'); +CREATE TABLE text ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "text" VALUES(1,'this item has not text... rly!'); +CREATE TABLE payload + (id INTEGER PRIMARY KEY, value BLOB); +CREATE TABLE storage ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE, + state INTEGER, + icon VARCHAR, + display_name VARCHAR + ); +INSERT INTO "storage" VALUES(1,'net',1,'stock_internet','Internet'); +INSERT INTO "storage" VALUES(2,'368c991f-8b59-4018-8130-3ce0ec944157',NULL,NULL,NULL); +CREATE TABLE event ( + id INTEGER, + timestamp INTEGER, + interpretation INTEGER, + manifestation INTEGER, + actor INTEGER, + payload INTEGER, + subj_id INTEGER, + subj_interpretation INTEGER, + subj_manifestation INTEGER, + subj_origin INTEGER, + subj_mimetype INTEGER, + subj_text INTEGER, + subj_storage INTEGER, + origin INTEGER, + subj_id_current INTEGER, + CONSTRAINT interpretation_fk + FOREIGN KEY(interpretation) + REFERENCES interpretation(id) + ON DELETE CASCADE, + CONSTRAINT manifestation_fk + FOREIGN KEY(manifestation) + REFERENCES manifestation(id) + ON DELETE CASCADE, + CONSTRAINT actor_fk + FOREIGN KEY(actor) + REFERENCES actor(id) + ON DELETE CASCADE, + CONSTRAINT origin_fk + FOREIGN KEY(origin) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT payload_fk + FOREIGN KEY(payload) + REFERENCES payload(id) + ON DELETE CASCADE, + CONSTRAINT subj_id_fk + FOREIGN KEY(subj_id) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_id_current_fk + FOREIGN KEY(subj_id_current) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_interpretation_fk + FOREIGN KEY(subj_interpretation) + REFERENCES interpretation(id) + ON DELETE CASCADE, + CONSTRAINT subj_manifestation_fk + FOREIGN KEY(subj_manifestation) + REFERENCES manifestation(id) + ON DELETE CASCADE, + CONSTRAINT subj_origin_fk + FOREIGN KEY(subj_origin) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_mimetype_fk + FOREIGN KEY(subj_mimetype) + REFERENCES mimetype(id) + ON DELETE CASCADE, + CONSTRAINT subj_text_fk + FOREIGN KEY(subj_text) + REFERENCES text(id) + ON DELETE CASCADE, + CONSTRAINT subj_storage_fk + FOREIGN KEY(subj_storage) + REFERENCES storage(id) + ON DELETE CASCADE, + CONSTRAINT unique_event UNIQUE (timestamp, interpretation, + manifestation, actor, subj_id) + ); +INSERT INTO "event" VALUES(1,1347652042579,1,1,1,0,2,2,2,1,1,1,2,NULL,2); +INSERT INTO "event" VALUES(2,143,3,3,2,0,5,4,4,1,2,1,2,3,5); +INSERT INTO "event" VALUES(3,133,5,5,3,0,2,6,2,1,2,1,2,6,2); +CREATE TABLE extensions_conf ( + extension VARCHAR, + key VARCHAR, + value BLOB, + CONSTRAINT unique_extension UNIQUE (extension, key) + ); +CREATE TABLE schema_version ( + schema VARCHAR PRIMARY KEY ON CONFLICT REPLACE, + version INT + ); +INSERT INTO "schema_version" VALUES('core',5); +CREATE UNIQUE INDEX uri_value ON uri(value); +CREATE UNIQUE INDEX interpretation_value + ON interpretation(value); +CREATE UNIQUE INDEX manifestation_value + ON manifestation(value); +CREATE UNIQUE INDEX mimetype_value + ON mimetype(value); +CREATE UNIQUE INDEX actor_value + ON actor(value); +CREATE UNIQUE INDEX text_value + ON text(value); +CREATE UNIQUE INDEX storage_value + ON storage(value); +CREATE INDEX event_id + ON event(id); +CREATE INDEX event_timestamp + ON event(timestamp); +CREATE INDEX event_interpretation + ON event(interpretation); +CREATE INDEX event_manifestation + ON event(manifestation); +CREATE INDEX event_actor + ON event(actor); +CREATE INDEX event_origin + ON event(origin); +CREATE INDEX event_subj_id + ON event(subj_id); +CREATE INDEX event_subj_id_current + ON event(subj_id_current); +CREATE INDEX event_subj_interpretation + ON event(subj_interpretation); +CREATE INDEX event_subj_manifestation + ON event(subj_manifestation); +CREATE INDEX event_subj_origin + ON event(subj_origin); +CREATE INDEX event_subj_mimetype + ON event(subj_mimetype); +CREATE INDEX event_subj_text + ON event(subj_text); +CREATE INDEX event_subj_storage + ON event(subj_storage); +CREATE UNIQUE INDEX extensions_conf_key + ON extensions_conf (extension, key); +CREATE VIEW event_view AS + SELECT event.id, + event.timestamp, + event.interpretation, + event.manifestation, + event.actor, + (SELECT value FROM payload + WHERE payload.id=event.payload) + AS payload, + (SELECT value FROM uri + WHERE uri.id=event.subj_id) + AS subj_uri, + event.subj_id, --//this points to an id in the uri table + event.subj_interpretation, + event.subj_manifestation, + event.subj_origin, + (SELECT value FROM uri + WHERE uri.id=event.subj_origin) + AS subj_origin_uri, + event.subj_mimetype, + (SELECT value FROM text + WHERE text.id = event.subj_text) + AS subj_text, + (SELECT value FROM storage + WHERE storage.id=event.subj_storage) + AS subj_storage, + (SELECT state FROM storage + WHERE storage.id=event.subj_storage) + AS subj_storage_state, + event.origin, + (SELECT value FROM uri + WHERE uri.id=event.origin) + AS event_origin_uri, + (SELECT value FROM uri + WHERE uri.id=event.subj_id_current) + AS subj_current_uri, + event.subj_id_current, + event.subj_text AS subj_text_id, + event.subj_storage AS subj_storage_id, + (SELECT value FROM actor + WHERE actor.id=event.actor) + AS actor_uri + FROM event +; +COMMIT; diff --git a/test/data/databases/090~alpha3.sql b/test/data/databases/090~alpha3.sql new file mode 100644 index 00000000..47ecdcb7 --- /dev/null +++ b/test/data/databases/090~alpha3.sql @@ -0,0 +1,237 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE uri ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "uri" VALUES(1,'file:///tmp'); +INSERT INTO "uri" VALUES(2,'http://www.google.de'); +INSERT INTO "uri" VALUES(3,'belly'); +INSERT INTO "uri" VALUES(5,'file:///tmp/foo.txt'); +INSERT INTO "uri" VALUES(6,'big bang'); +CREATE TABLE interpretation ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + value VARCHAR UNIQUE + ); +INSERT INTO "interpretation" VALUES(1,'stfu:OpenEvent'); +INSERT INTO "interpretation" VALUES(2,'stfu:Document'); +INSERT INTO "interpretation" VALUES(3,'stfu:ShalalalalaEvent'); +INSERT INTO "interpretation" VALUES(4,'stfu:Image'); +INSERT INTO "interpretation" VALUES(5,'stfu:FoobarEvent'); +INSERT INTO "interpretation" VALUES(6,'stfu:Test'); +CREATE TABLE manifestation ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + value VARCHAR UNIQUE + ); +INSERT INTO "manifestation" VALUES(1,'stfu:YourActivity'); +INSERT INTO "manifestation" VALUES(2,'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject'); +INSERT INTO "manifestation" VALUES(3,'stfu:BooActivity'); +INSERT INTO "manifestation" VALUES(4,'stfu:Ethereal'); +INSERT INTO "manifestation" VALUES(5,'stfu:SomeActivity'); +CREATE TABLE mimetype ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + value VARCHAR UNIQUE + ); +INSERT INTO "mimetype" VALUES(1,'meat/raw'); +INSERT INTO "mimetype" VALUES(2,'text/plain'); +CREATE TABLE actor ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + value VARCHAR UNIQUE + ); +INSERT INTO "actor" VALUES(1,'firefox'); +INSERT INTO "actor" VALUES(2,'geany'); +INSERT INTO "actor" VALUES(3,'gedit'); +CREATE TABLE text ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE + ); +INSERT INTO "text" VALUES(1,'this item has not text... rly!'); +CREATE TABLE payload + (id INTEGER PRIMARY KEY, value BLOB); +CREATE TABLE storage ( + id INTEGER PRIMARY KEY, + value VARCHAR UNIQUE, + state INTEGER, + icon VARCHAR, + display_name VARCHAR + ); +INSERT INTO "storage" VALUES(1,'net',1,'stock_internet','Internet'); +INSERT INTO "storage" VALUES(2,'368c991f-8b59-4018-8130-3ce0ec944157',NULL,NULL,NULL); +CREATE TABLE event ( + id INTEGER, + timestamp INTEGER, + interpretation INTEGER, + manifestation INTEGER, + actor INTEGER, + payload INTEGER, + subj_id INTEGER, + subj_interpretation INTEGER, + subj_manifestation INTEGER, + subj_origin INTEGER, + subj_mimetype INTEGER, + subj_text INTEGER, + subj_storage INTEGER, + origin INTEGER, + subj_id_current INTEGER, + CONSTRAINT interpretation_fk + FOREIGN KEY(interpretation) + REFERENCES interpretation(id) + ON DELETE CASCADE, + CONSTRAINT manifestation_fk + FOREIGN KEY(manifestation) + REFERENCES manifestation(id) + ON DELETE CASCADE, + CONSTRAINT actor_fk + FOREIGN KEY(actor) + REFERENCES actor(id) + ON DELETE CASCADE, + CONSTRAINT origin_fk + FOREIGN KEY(origin) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT payload_fk + FOREIGN KEY(payload) + REFERENCES payload(id) + ON DELETE CASCADE, + CONSTRAINT subj_id_fk + FOREIGN KEY(subj_id) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_id_current_fk + FOREIGN KEY(subj_id_current) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_interpretation_fk + FOREIGN KEY(subj_interpretation) + REFERENCES interpretation(id) + ON DELETE CASCADE, + CONSTRAINT subj_manifestation_fk + FOREIGN KEY(subj_manifestation) + REFERENCES manifestation(id) + ON DELETE CASCADE, + CONSTRAINT subj_origin_fk + FOREIGN KEY(subj_origin) + REFERENCES uri(id) + ON DELETE CASCADE, + CONSTRAINT subj_mimetype_fk + FOREIGN KEY(subj_mimetype) + REFERENCES mimetype(id) + ON DELETE CASCADE, + CONSTRAINT subj_text_fk + FOREIGN KEY(subj_text) + REFERENCES text(id) + ON DELETE CASCADE, + CONSTRAINT subj_storage_fk + FOREIGN KEY(subj_storage) + REFERENCES storage(id) + ON DELETE CASCADE, + CONSTRAINT unique_event UNIQUE (timestamp, interpretation, + manifestation, actor, subj_id) + ); +INSERT INTO "event" VALUES(1,1347652042579,1,1,1,0,2,2,2,1,1,1,2,NULL,2); +INSERT INTO "event" VALUES(2,143,3,3,2,0,5,4,4,1,2,1,2,3,5); +INSERT INTO "event" VALUES(3,133,5,5,3,0,2,6,2,1,2,1,2,6,2); +CREATE TABLE extensions_conf ( + extension VARCHAR, + key VARCHAR, + value BLOB, + CONSTRAINT unique_extension UNIQUE (extension, key) + ); +CREATE TABLE schema_version ( + schema VARCHAR PRIMARY KEY ON CONFLICT REPLACE, + version INT + ); +INSERT INTO "schema_version" VALUES('core',6); +DELETE FROM sqlite_sequence; +INSERT INTO "sqlite_sequence" VALUES('interpretation',6); +INSERT INTO "sqlite_sequence" VALUES('manifestation',5); +INSERT INTO "sqlite_sequence" VALUES('actor',3); +INSERT INTO "sqlite_sequence" VALUES('mimetype',2); +CREATE UNIQUE INDEX uri_value ON uri(value); +CREATE UNIQUE INDEX interpretation_value + ON interpretation(value); +CREATE UNIQUE INDEX manifestation_value + ON manifestation(value); +CREATE UNIQUE INDEX mimetype_value + ON mimetype(value); +CREATE UNIQUE INDEX actor_value + ON actor(value); +CREATE UNIQUE INDEX text_value + ON text(value); +CREATE UNIQUE INDEX storage_value + ON storage(value); +CREATE INDEX event_id + ON event(id); +CREATE INDEX event_timestamp + ON event(timestamp); +CREATE INDEX event_interpretation + ON event(interpretation); +CREATE INDEX event_manifestation + ON event(manifestation); +CREATE INDEX event_actor + ON event(actor); +CREATE INDEX event_origin + ON event(origin); +CREATE INDEX event_subj_id + ON event(subj_id); +CREATE INDEX event_subj_id_current + ON event(subj_id_current); +CREATE INDEX event_subj_interpretation + ON event(subj_interpretation); +CREATE INDEX event_subj_manifestation + ON event(subj_manifestation); +CREATE INDEX event_subj_origin + ON event(subj_origin); +CREATE INDEX event_subj_mimetype + ON event(subj_mimetype); +CREATE INDEX event_subj_text + ON event(subj_text); +CREATE INDEX event_subj_storage + ON event(subj_storage); +CREATE UNIQUE INDEX extensions_conf_key + ON extensions_conf (extension, key); +CREATE VIEW event_view AS + SELECT event.id, + event.timestamp, + event.interpretation, + event.manifestation, + event.actor, + (SELECT value FROM payload + WHERE payload.id=event.payload) + AS payload, + (SELECT value FROM uri + WHERE uri.id=event.subj_id) + AS subj_uri, + event.subj_id, --//this points to an id in the uri table + event.subj_interpretation, + event.subj_manifestation, + event.subj_origin, + (SELECT value FROM uri + WHERE uri.id=event.subj_origin) + AS subj_origin_uri, + event.subj_mimetype, + (SELECT value FROM text + WHERE text.id = event.subj_text) + AS subj_text, + (SELECT value FROM storage + WHERE storage.id=event.subj_storage) + AS subj_storage, + (SELECT state FROM storage + WHERE storage.id=event.subj_storage) + AS subj_storage_state, + event.origin, + (SELECT value FROM uri + WHERE uri.id=event.origin) + AS event_origin_uri, + (SELECT value FROM uri + WHERE uri.id=event.subj_id_current) + AS subj_current_uri, + event.subj_id_current, + event.subj_text AS subj_text_id, + event.subj_storage AS subj_storage_id, + (SELECT value FROM actor + WHERE actor.id=event.actor) + AS actor_uri + FROM event +; +COMMIT; diff --git a/test/data/upgrade_test.js b/test/data/upgrade_test.js index b4091dcc..17efd9b2 100644 --- a/test/data/upgrade_test.js +++ b/test/data/upgrade_test.js @@ -8,7 +8,7 @@ { "uri" : "http://www.google.de", "interpretation" : "stfu:Document", - "manifestation" : "stfu:File", + "manifestation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject", "origin" : "file:///tmp", "mimetype" : "meat/raw", "text" : "this item has not text... rly!", @@ -42,7 +42,7 @@ { "uri" : "http://www.google.de", "interpretation" : "stfu:Test", - "manifestation" : "stfu:File", + "manifestation" : "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject", "origin" : "file:///tmp", "mimetype" : "text/plain", "text" : "this item has not text... rly!", diff --git a/test/dbus/upgrade-test.py b/test/dbus/upgrade-test.py index 4bea3116..fd57bc9e 100644 --- a/test/dbus/upgrade-test.py +++ b/test/dbus/upgrade-test.py @@ -51,12 +51,39 @@ class ZeitgeistUpgradeTest(testutils.RemoteTestCase): def sanity_check(self): events = self.findEventsForTemplatesAndWait([]) - self.assertEquals(len(events), 3) + original_events = parse_events("test/data/upgrade_test.js") + + # Ensure no events got lost (or duplicated) + self.assertEquals(len(events), len(original_events)) + + # Ensure no subjects got lost + for i in range(len(events)): + self.assertEquals(len(events[i].subjects), + len(original_events[i].subjects)) + + # Ensure data didn't change (unless it should) + for i in range(len(events)): + a = events[i] + b = original_events[i] + self.assertEquals(a.timestamp, b.timestamp) + self.assertEquals(a.interpretation, b.interpretation) + self.assertEquals(a.manifestation, b.manifestation) + self.assertEquals(a.actor, b.actor) + for j in range(len(a.subjects)): + sa = a.subjects[j] + sb = b.subjects[j] + self.assertEquals(sa.uri, sb.uri) + self.assertEquals(sa.interpretation, sb.interpretation) + if not sa.uri.startswith("http://"): + self.assertEquals(sa.manifestation, sb.manifestation) + self.assertEquals(sa.origin, sb.origin) + self.assertEquals(sa.mimetype, sb.mimetype) + self.assertEquals(sa.text, sb.text) + self.assertEquals(sa.storage, sb.storage) # Introduced in Zeitgeist 0.8.0: # - event.origin # - subject.current_uri - # - subject.storage for event in events: self.assertEquals(event.origin, "") for subject in event.subjects: @@ -64,10 +91,36 @@ class ZeitgeistUpgradeTest(testutils.RemoteTestCase): # Introduced in Bluebird Alpha 2: # - WebDataObject + for event in events: + for subject in event.subjects: + if subject.uri.startswith("http://"): + self.assertEquals(subject.manifestation, Manifestation.WEB_DATA_OBJECT) + + # Introduced in Zeitgeist 1.0 Beta 1 + # - subject.current_origin + for event in events: + for subject in event.subjects: + self.assertEquals(subject.current_origin, subject.origin) def testUpgradeFrom071(self): self.prepare("071") self.sanity_check() + def testUpgradeFrom080(self): + self.prepare("080") + self.sanity_check() + + def testUpgradeFrom090a1(self): + self.prepare("090~alpha1") + self.sanity_check() + + def testUpgradeFrom090a2(self): + self.prepare("090~alpha2") + self.sanity_check() + + def testUpgradeFrom090a3(self): + self.prepare("090~alpha3") + self.sanity_check() + if __name__ == "__main__": unittest.main() |