def test_delete(self): l1 = len(listdir(self.tmpfolder)) p = [("id", "utf8test")] t = AppTester(self.admin, p, url="http://example.com/s/delete") r = t.run_get() self.assertEquals(len(listdir(self.tmpfolder)), l1-1) validate.validate_admin(XML(r.body))
def test_delete(self): l1 = len(listdir(self.tmpfolder)) p = [("id", "utf8test")] t = AppTester(self.admin, p, url="http://example.com/s/delete") r = t.run_get() self.assertEquals(len(listdir(self.tmpfolder)), l1 - 1) validate.validate_admin(XML(r.body))
def testIt(self): a = Admin("test.xsl") a.add(u"test", AdminTestApp, u"Test app") a.add(u"test2", AdminTestApp, u"Test app 2") a.compile() t = AppTester(a, [], "http://example.com/test/create") r = t.run_get(True) validate_admin(XML(r.body))
def test_pattern(self): s = StaticFiles(self.folder, follow_symlinks=True, pattern="(^[a-z.]+$)|(^tst/.*$)") r = AppTester(s, url="http://example.com/test.txt").run_get() self.assertEquals(r.body, "hello world") r = AppTester(s, url="http://example.com/tst/").run_get() self.assert_(r.body_ncontains("test2link", 2)) s = StaticFiles(self.folder, pattern="(?!^(tst)|(tst/.*)$)") r = AppTester(s, url="http://example.com/tst").run_get() self.assertEquals(r.body, "tst does not exist")
def test_save(self): p = [("e_id", "hello_world"), ("e_heading", "Hello World"), ("e_summary", "This is a test"), ("e_tags", "testtag, infotag"), ("e_post", "<p>Welcome to the test post</p>")] t = AppTester(self.admin, p, url="http://example.com/s/save") r = t.run_get() validate.validate_admin(XML(r.body)) path = join(self.tmpfolder, "hello_world") self.assert_(isfile(path)) post = open(path, "rb").read() self.assert_(post.count("testtag", 1)) self.assert_(post.count("infotag", 1))
def test_save(self): p = [ ("e_id", "hello_world"), ("e_heading", "Hello World"), ("e_summary", "This is a test"), ("e_tags", "testtag, infotag"), ("e_post", "<p>Welcome to the test post</p>") ] t = AppTester(self.admin, p, url="http://example.com/s/save") r = t.run_get() validate.validate_admin(XML(r.body)) path = join(self.tmpfolder, "hello_world") self.assert_(isfile(path)) post = open(path, "rb").read() self.assert_(post.count("testtag", 1)) self.assert_(post.count("infotag", 1))
def testHttpError(self): a = ErrorHandler(http_err_app, use_log=False) t = AppTester(a) b = t.run_get().body self.assert_(b.count("404"))
def testOtherError(self): a = ErrorHandler(other_err_app, use_log=False) t = AppTester(a) b = t.run_get().body self.assertEquals(b, 'Internal server error')
def testUserError(self): a = ErrorHandler(user_err_app, use_log=False) t = AppTester(a) b = t.run_get().body self.assert_(b.count("<h1>short"))
def test_folder(self): s = StaticFiles(self.folder) r = AppTester(s, url="http://example.com").run_get() self.assert_(r.body_ncontains("<a href='test2.txt'>")) self.assert_(r.body_ncontains("test1link", 0))
def test_save_error(self): t = AppTester(self.admin, [], url="http://example.com/s/save") r = t.run_get() validate.validate_admin(XML(r.body))
def test_create(self): t = AppTester(self.admin, url="http://example.com/s/create") r = t.run_get() validate.validate_admin(XML(r.body))
def test_edit(self): p = [("id", "utf8test")] t = AppTester(self.admin, p, url="http://example.com/s/edit") r = t.run_get() validate.validate_admin(XML(r.body))
def test_folder_symlink(self): s = StaticFiles(self.folder, follow_symlinks=True) r = AppTester(s, url="http://example.com").run_get() self.assert_(r.body_ncontains("test1link", 2))