From 815fb9da83b3f250d9a3698e318a5c1d2b16943d Mon Sep 17 00:00:00 2001 From: calvin Date: Mon, 19 Dec 2005 14:06:53 +0000 Subject: [PATCH] more tests git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2991 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/tests/test_cookies.py | 77 +++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/linkcheck/tests/test_cookies.py b/linkcheck/tests/test_cookies.py index 458588d1..874ad83f 100644 --- a/linkcheck/tests/test_cookies.py +++ b/linkcheck/tests/test_cookies.py @@ -28,7 +28,7 @@ class TestCookies (tests.StandardTest): Test list dictionary routines. """ - def test_cookie (self): + def test_netscape_cookie1 (self): data = ( ("Foo", "Bar"), ("Comment", "justatest"), @@ -46,7 +46,7 @@ class TestCookies (tests.StandardTest): self.assert_(cookie.is_valid_for("http", host, 80, "/")) self.assert_(cookie.is_valid_for("https", host, 443, "/a")) - def test_cookie_expired (self): + def test_netscape_cookie2 (self): data = ( ("Foo", "Bar"), ("Comment", "justatest"), @@ -62,7 +62,7 @@ class TestCookies (tests.StandardTest): cookie = linkcheck.cookies.NetscapeCookie(value, scheme, host, path) self.assert_(cookie.is_expired()) - def test_cookie_invalid (self): + def test_netscape_cookie3 (self): data = ( ("Foo", "Bar\""), ("Port", "hul,la"), @@ -75,6 +75,77 @@ class TestCookies (tests.StandardTest): self.assertRaises(linkcheck.cookies.CookieError, linkcheck.cookies.NetscapeCookie, value, scheme, host, path) + def test_netscape_cookie4 (self): + data = ( + ("Foo", "Bar\""), + ("Port", "100,555,76"), + ) + parts = ['%s="%s"' % (key, value) for key, value in data] + value = "; ".join(parts) + scheme = "http" + host = "localhost" + path = "/" + cookie = linkcheck.cookies.NetscapeCookie(value, scheme, host, path) + + def test_rfc_cookie1 (self): + data = ( + ("Foo", "Bar"), + ("Comment", "justatest"), + ("Max-Age", "1000"), + ("Path", "/"), + ("Version", "1"), + ) + parts = ['%s="%s"' % (key, value) for key, value in data] + value = "; ".join(parts) + scheme = "http" + host = "localhost" + path = "/" + cookie = linkcheck.cookies.Rfc2965Cookie(value, scheme, host, path) + self.assert_(cookie.check_expired()) + self.assert_(cookie.is_valid_for("http", host, 80, "/")) + self.assert_(cookie.is_valid_for("https", host, 443, "/a")) + + def test_rfc_cookie2 (self): + data = ( + ("Foo", "Bar"), + ("Comment", "justatest"), + ("Max-Age", "0"), + ("Path", "/"), + ("Version", "1"), + ) + parts = ['%s="%s"' % (key, value) for key, value in data] + value = "; ".join(parts) + scheme = "http" + host = "localhost" + path = "/" + cookie = linkcheck.cookies.Rfc2965Cookie(value, scheme, host, path) + self.assert_(cookie.is_expired()) + + def test_rfc_cookie3 (self): + data = ( + ("Foo", "Bar\""), + ("Port", "hul,la"), + ) + parts = ['%s="%s"' % (key, value) for key, value in data] + value = "; ".join(parts) + scheme = "http" + host = "localhost" + path = "/" + self.assertRaises(linkcheck.cookies.CookieError, + linkcheck.cookies.Rfc2965Cookie, value, scheme, host, path) + + def test_rfc_cookie4 (self): + data = ( + ("Foo", "Bar\""), + ("Port", "100,555,76"), + ) + parts = ['%s="%s"' % (key, value) for key, value in data] + value = "; ".join(parts) + scheme = "http" + host = "localhost" + path = "/" + cookie = linkcheck.cookies.Rfc2965Cookie(value, scheme, host, path) + def test_suite (): """