def test_filters(self): app = self.archive.apps['site'] self.context['.app'] = app with pilot.manage(self.context): self.assertEqual(1000, self.context.eval("10|'cube'")) self.assertEqual(1000, self.context.eval("10|'cube from site'")) self.assertEqual(1000, self.context.eval("10|.app.filters.cube"))
def test_owned(self): """Test owned objects""" context = self.context call = self.archive.call with pilot.manage(context): call('dbtest#make_post', context, None) post = call('dbtest#get_post', context, None, name="post") assert post.name == 'post', "post should be called 'post'" assert post.images[0].name == 'images1', 'expected images1' images = call('dbtest#get_images', context, None, name="images1") assert images.name == 'images1', "images should be named 'images1'" call('dbtest#delete_post', context, None, name="post") images = call('dbtest#get_images', context, None, name="images1") assert not images, "images should have been deleted"
def test_owner(self): """Test object ownership""" context = self.context call = self.archive.call with pilot.manage(context): call("dbtest#owner_test", context, None) owner = call("dbtest#get_owner", context, None, name="owner") print(owner) self.assertEqual(owner.name, 'owner') child1 = call("dbtest#get_child", context, None, name="child1") child2 = call("dbtest#get_child", context, None, name="child2") child3 = call("dbtest#get_child", context, None, name="child3") child4 = call("dbtest#get_child", context, None, name="child4") print(child1, child2, child3, child4) assert child1, "child1 should exist" assert child2, "child2 should exist" assert child3, "child3 should exist" assert child4, "child4 should exist" assert owner.unowned_child is child1 assert owner.owned_child is child2 assert owner.unowned_child_o2o is child3 assert owner.owned_child_o2o is child4 call("dbtest#delete_owner", context, None, name="owner") print(owner) owner = call("dbtest#get_owner", context, None, name="owner") print(owner) assert not owner, "owner is {}".format(owner) child1 = call("dbtest#get_child", context, None, name="child1") child2 = call("dbtest#get_child", context, None, name="child2") child3 = call("dbtest#get_child", context, None, name="child1") child4 = call("dbtest#get_child", context, None, name="child2") print(child1, child2, child3, child4) assert child1, "child1 should exists" assert not child2, "child2 should not exists" assert child3, "child3 should exists" assert not child4, "child4 should not exists"