def test_html_list(): serializer = Serializer('html') bags = [Bag('bag' + str(name)) for name in range(2)] string = ''.join(serializer.list_bags(bags)) assert 'href="bags/bag0' in string assert 'href="bags/bag1' in string
def list(environ, start_response): """ List all the bags that the current user can read. """ store = environ["tiddlyweb.store"] bags = store.list_bags() kept_bags = [] for bag in bags: try: bag.skinny = True bag = store.get(bag) bag.policy.allows(environ["tiddlyweb.usersign"], "read") kept_bags.append(bag) except (UserRequiredError, ForbiddenError): pass try: serialize_type, mime_type = web.get_serialize_type(environ) serializer = Serializer(serialize_type, environ) content = serializer.list_bags(kept_bags) except NoSerializationError: raise HTTP415("Content type not supported: %s" % mime_type) start_response("200 OK", [("Content-Type", mime_type)]) return [content]
def test_text_list(): serializer = Serializer('text') bags = [Bag('bag' + str(name)) for name in range(2)] string = ''.join(serializer.list_bags(bags)) assert 'bag0' in string assert 'bag1' in string
def test_html_list(): serializer = Serializer("html") bags = [Bag("bag" + str(name)) for name in xrange(2)] string = serializer.list_bags(bags) assert 'href="bags/bag0' in string assert 'href="bags/bag1' in string
def test_text_list(): serializer = Serializer("text") bags = [Bag("bag" + str(name)) for name in xrange(2)] string = serializer.list_bags(bags) assert "bag0" in string assert "bag1" in string
def test_html_list(): serializer = Serializer('html') bags = [Bag('bag' + str(name)) for name in xrange(2)] string = ''.join(serializer.list_bags(bags)) assert 'href="bags/bag0' in string assert 'href="bags/bag1' in string
def test_text_list(): serializer = Serializer('text') bags = [Bag('bag' + str(name)) for name in xrange(2)] string = ''.join(serializer.list_bags(bags)) assert 'bag0' in string assert 'bag1' in string