def test_ls(self): expected = sorted([self.url + ex for ex in ("Foo/", urllib.quote(u"fooö".encode("utf-8")), "huge", "incoming/")]) self.assertEqual(sorted(lib.ls(self.url)), expected) foobarpath = os.path.join(config.SHARE_PATH, "foobar") open(foobarpath, "w").close() self.assertEqual(sorted(lib.ls(self.url)), expected) lib.reset_cache() self.assertEqual(sorted(lib.ls(self.url)), sorted(expected + [self.url + "foobar"])) os.remove(foobarpath)
def setUp(self): self.url = u"http://localhost:" + str(config.PORT) + "/" os.mkdir(config.INCOMING_PATH) foo = os.path.join(config.SHARE_PATH, "Foo") os.mkdir(foo) bar = os.path.join(foo, "bar") os.mkdir(bar) for name in [".invisible", u"fooö", "Foo/oOo","Foo/cover.jpg", "Foo/bar/spam"]: name = name.replace("/", os.path.sep).encode(config.FS_ENCODING) fname = os.path.join(config.SHARE_PATH, name) f = open(fname, "w") f.write("test") f.close() for name in ["huge", "Foo/bar/huge"]: name.replace("/", os.path.sep) fname = os.path.join(config.SHARE_PATH, name) f = open(fname, "w") data = "ABCDEFGH"*128 for i in xrange(self.huge_size/len(data)): f.write(data) f.close() lib.reset_cache()