summaryrefslogtreecommitdiff
path: root/test/test_schema_manipulation.py
diff options
context:
space:
mode:
authornitromaster101@gmail.com <nitromaster101@gmail.com@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-07-22 18:45:54 +0000
committernitromaster101@gmail.com <nitromaster101@gmail.com@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-07-22 18:45:54 +0000
commitbc7d69f0956d1a66ffc9d3f4b645f6419e847331 (patch)
treea3b99784e9c3016b972e13bba07c90128fd6de32 /test/test_schema_manipulation.py
parent605b7096f3fbbe7cf000d7464e480d66fee3aa42 (diff)
cleanup, incorporate changes from code review, and move merge and split stuff into freebase.experimental
git-svn-id: http://freebase-python.googlecode.com/svn/trunk@201 5914aa95-5b3a-0410-a3b5-7b719e7fe9b2
Diffstat (limited to 'test/test_schema_manipulation.py')
-rw-r--r--test/test_schema_manipulation.py40
1 files changed, 31 insertions, 9 deletions
diff --git a/test/test_schema_manipulation.py b/test/test_schema_manipulation.py
index f8453e7..12151d7 100644
--- a/test/test_schema_manipulation.py
+++ b/test/test_schema_manipulation.py
@@ -8,7 +8,9 @@ import getlogindetails
from freebase.api import HTTPMetawebSession, MetawebError
from freebase.schema import create_type, reciprocate_property, delegate_property
-from freebase.schema import create_property, type_object, copy_property, move_property
+from freebase.schema import create_property, add_type_to_object, copy_property, move_property
+from freebase.schema import create_object, connect_object, disconnect_object
+from freebase.schema import move_object
USERNAME = 'username'
PASSWORD = 'password'
@@ -31,28 +33,27 @@ f = lambda x: x["id"]
class TestSchemaManipulation(unittest.TestCase):
def test_make_and_type_object(self):
- a = s.create_object("A", path=domain_id + "/a")
+ a = create_object(s, "A", path=domain_id + "/a")
self.assertEqual(a.create, "created")
- b = s.create_object("B", path=domain_id + "/b", included_types=["/people/person"])
+ b = create_object(s, "B", path=domain_id + "/b", included_types=["/people/person"])
q = { "id" : b.id, "type" : [{"id" : None}] }
- types = map(f, s.mqlread(q)["type"])
+ types = [x["id"] for x in s.mqlread(q)["type"]]
self.assertEqual("/common/topic" in types, True)
self.assertEqual("/people/person" in types, True)
self.assertEqual("/film/actor" in types, False)
- type_object(s, b.id, "/film/film_genre")
+ add_type_to_object(s, b.id, "/film/film_genre")
- types = map(f, s.mqlread(q)["type"])
+ types = [x["id"] for x in s.mqlread(q)["type"]]
self.assertEqual("/film/film_genre" in types, True)
self.assertEqual("/media_common/media_genre" in types, True)
def test_move_object(self):
- print domain_id
- old = s.create_object("old", domain_id + "/old")
- s.move_object(domain_id + "/old", domain_id + "/new")
+ old = create_object(s, "old", domain_id + "/old")
+ move_object(s, domain_id + "/old", domain_id + "/new")
is_old = { "id" : domain_id + "/old", "key" : [{"value" : None}]}
is_new = { "id" : domain_id + "/new", "key" : [{"value" : None}]}
s.touch()
@@ -130,6 +131,27 @@ class TestSchemaManipulation(unittest.TestCase):
#delegator property test
delegate_property(s, "/people/person/date_of_birth", player, "Date of Birth", "db")
+ def test_create_over_created(self):
+ """ No creating a property on top of an already created one..."""
+ create_type(s, "Rapper", "rapper", domain_id)
+ create_property(s, "Styles", "styles", domain_id+"/rapper", "/music/genre")
+
+ # now we mistakenly create the same prop
+ # it should just exit as if it finished successfully... but, it shouldn't actually do anything
+ create_property(s, "Styles", "styles", domain_id+"/rapper", "/music/genre")
+ # we also mistakenly create the same type, again
+ create_type(s, "Rapper", "rapper", domain_id)
+
+ def test_reciprocating_reciprocated(self):
+ """ You can't reciprocate an already reciprocated property"""
+ create_type(s, "Master", "master", domain_id)
+ create_type(s, "Servant", "servant", domain_id)
+
+ create_property(s, "Servants", "servants", domain_id + "/master", domain_id + "/servant", unique=False)
+ reciprocate_property(s, "Masters", "masters", domain_id + "/master/servants", unique=False)
+
+ self.assertRaises(MetawebError, lambda: reciprocate_property(s, "Buddies", "buddies", domain_id + "/master/servants", unique=False))
+
if __name__ == '__main__':
unittest.main()