def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") self.testtype = RecordType(self.testcoll, "testtype") self.testdata = RecordTypeData(self.testcoll, "testtype") return
def test_recordtype_init(self): t = RecordType(self.testcoll, "testtype", self.testsite) u = recordtype_coll_url(self.testsite, coll_id="testcoll", type_id="testtype") self.assertEqual(t._entitytype, ANNAL.CURIE.Type) self.assertEqual(t._entityfile, layout.TYPE_META_FILE) self.assertEqual(t._entityref, layout.META_TYPE_REF) self.assertEqual(t._entityid, "testtype") self.assertEqual(t._entityurl, u) self.assertEqual(t._entitydir, recordtype_dir(type_id="testtype")) self.assertEqual(t._values, None) return
def test_recordtype1_data(self): t = RecordType(self.testcoll, "type1", self.testsite) self.assertEqual(t.get_id(), "type1") self.assertEqual(t.get_type_id(), "_type") self.assertIn("/c/testcoll/_annalist_collection/types/type1/", t.get_url()) self.assertEqual(TestBaseUri + "/c/testcoll/d/_type/type1/", t.get_view_url()) t.set_values(recordtype_create_values(type_id="type1")) td = t.get_values() self.assertEqual(set(td.keys()), set(recordtype_value_keys())) v = recordtype_values(type_id="type1") self.assertDictionaryMatch(td, v) return
def test_recordtype2_data(self): t = RecordType(self.testcoll, "type2") self.assertEqual(t.get_id(), "type2") self.assertEqual(t.get_type_id(), layout.TYPE_TYPEID) self.assertIn( "/c/testcoll/_annalist_collection/%(type_dir)s/type2/" % self.layout, t.get_url()) self.assertEqual( TestBaseUri + "/c/testcoll/d/%(type_typeid)s/type2/" % self.layout, t.get_view_url()) t.set_values(recordtype_create_values(type_id="type2")) td = t.get_values() self.assertEqual(set(td.keys()), set(recordtype_value_keys())) v = recordtype_values(type_id="type2") self.assertDictionaryMatch(td, v) return
def setUp(self): init_annalist_test_site() self.testsite = Site(TestBaseUri, TestBaseDir) self.testcoll = Collection(self.testsite, "testcoll") self.testcoll1_a = Collection(self.testsite, "testcoll1") self.testcoll1_b = Collection(self.testsite, "testcoll1") self.testcoll2_a = Collection(self.testsite, "testcoll2") self.testcoll2_b = Collection(self.testsite, "testcoll2") self.typecache = CollectionTypeCache() self.type1 = RecordType(self.testcoll1_a, "type1") self.type1.set_values( recordtype_create_values(type_id="type1", type_uri="test:type1", supertype_uris=[])) self.type11 = RecordType(self.testcoll1_a, "type11") self.type11.set_values( recordtype_create_values(type_id="type11", type_uri="test:type11", supertype_uris=["test:type1"])) self.type111 = RecordType(self.testcoll1_a, "type111") self.type111.set_values( recordtype_create_values(type_id="type111", type_uri="test:type111", supertype_uris=["test:type11"])) self.type12 = RecordType(self.testcoll1_a, "type12") self.type12.set_values( recordtype_create_values(type_id="type12", type_uri="test:type12", supertype_uris=["test:type1"])) self.type2 = RecordType(self.testcoll1_a, "type2") self.type2.set_values( recordtype_create_values(type_id="type2", type_uri="test:type2", supertype_uris=[])) self.type21 = RecordType(self.testcoll1_a, "type21") self.type21.set_values( recordtype_create_values(type_id="type21", type_uri="test:type21", supertype_uris=["test:type2"])) self.type22 = RecordType(self.testcoll1_a, "type22") self.type22.set_values( recordtype_create_values(type_id="type22", type_uri="test:type22", supertype_uris=["test:type2"])) return