Example #1
0
	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))
Example #2
0
 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))
Example #3
0
	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))
Example #4
0
	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")
Example #5
0
    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))
Example #6
0
	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))
Example #7
0
 def testHttpError(self):
     a = ErrorHandler(http_err_app, use_log=False)
     t = AppTester(a)
     b = t.run_get().body
     self.assert_(b.count("404"))
Example #8
0
	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')
Example #9
0
 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"))
Example #10
0
	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))
Example #11
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))
Example #12
0
 def test_create(self):
     t = AppTester(self.admin, url="http://example.com/s/create")
     r = t.run_get()
     validate.validate_admin(XML(r.body))
Example #13
0
 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))
Example #14
0
	def testHttpError(self):
		a = ErrorHandler(http_err_app, use_log=False)
		t = AppTester(a)
		b = t.run_get().body
		self.assert_(b.count("404"))
Example #15
0
 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')
Example #16
0
	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))
Example #17
0
	def test_create(self):
		t = AppTester(self.admin, url="http://example.com/s/create")
		r = t.run_get()
		validate.validate_admin(XML(r.body))
Example #18
0
	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))
Example #19
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))
Example #20
0
	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"))