def test_load_from_zipfile_filename_not_found(self): strm = StringIO('w') zipf = zipfile.ZipFile(strm, 'w') zipf.writestr('foo.foo', '') zipf.close() colls = [get_root_collection(IMyEntity)] colls = load_into_collections_from_zipfile(colls, strm) self.assert_equal(len(colls[0]), 0)
def test_load_from_zipfile_invalid_extension(self): strm = StringIO('w') zipf = zipfile.ZipFile(strm, 'w') coll_name = get_collection_name(get_collection_class(IMyEntity)) zipf.writestr('%s.foo' % coll_name, '') zipf.close() colls = [get_root_collection(IMyEntity)] with self.assert_raises(ValueError) as cm: dummy = load_into_collections_from_zipfile(colls, strm) exc_msg = 'Could not infer MIME type' self.assert_true(cm.exception.message.startswith(exc_msg))
def test_load_from_zipfile(self): member = _make_test_entity_member() strm = StringIO('w') dump_resource_to_zipfile(member, strm) colls = [ get_root_collection(IMyEntityParent), get_root_collection(IMyEntity), get_root_collection(IMyEntityChild), get_root_collection(IMyEntityGrandchild), ] colls = load_into_collections_from_zipfile(colls, strm) self.assert_equal(len(colls[0]), 1) self.assert_equal(len(colls[1]), 1) self.assert_equal(len(colls[2]), 1) self.assert_equal(len(colls[3]), 1)