| 1 | import unittest |
| 2 | |
| 3 | from pygopherd.protocols import gemini, gopherp, http, rfc1436, spartan, wap |
| 4 | from pygopherd.testutil import get_testing_protocol |
| 5 | |
| 6 | |
| 7 | class ProtocolMultiplexerTestCase(unittest.TestCase): |
| 8 | def test_gopher(self): |
| 9 | proto = get_testing_protocol("/gopher0-request.txt\n") |
| 10 | self.assertIsInstance(proto, rfc1436.GopherProtocol) |
| 11 | |
| 12 | def test_secure_gopher(self): |
| 13 | proto = get_testing_protocol("/gopher0-request.txt\n", use_tls=True) |
| 14 | self.assertIsInstance(proto, rfc1436.SecureGopherProtocol) |
| 15 | |
| 16 | def test_gopher_plus(self): |
| 17 | proto = get_testing_protocol("/gopher+-request.txt\t+\n") |
| 18 | self.assertIsInstance(proto, gopherp.GopherPlusProtocol) |
| 19 | |
| 20 | def test_secure_gopher_plus(self): |
| 21 | proto = get_testing_protocol("/gopher+-request.txt\t+\n", use_tls=True) |
| 22 | self.assertIsInstance(proto, gopherp.SecureGopherPlusProtocol) |
| 23 | |
| 24 | def test_http(self): |
| 25 | proto = get_testing_protocol("GET /http-request.txt HTTP/1.0\n\n") |
| 26 | self.assertIsInstance(proto, http.HTTPProtocol) |
| 27 | |
| 28 | def test_https(self): |
| 29 | proto = get_testing_protocol("GET /http-request.txt HTTP/1.0\n\n", use_tls=True) |
| 30 | self.assertIsInstance(proto, http.HTTPSProtocol) |
| 31 | |
| 32 | def test_wap(self): |
| 33 | proto = get_testing_protocol("GET /wap/http-request.txt HTTP/1.0\n\n") |
| 34 | self.assertIsInstance(proto, wap.WAPProtocol) |
| 35 | |
| 36 | def test_gemini(self): |
| 37 | proto = get_testing_protocol("gemini://example.com\n", use_tls=True) |
| 38 | self.assertIsInstance(proto, gemini.GeminiProtocol) |
| 39 | |
| 40 | def test_spartan(self): |
| 41 | proto = get_testing_protocol("localhost / 0\n") |
| 42 | self.assertIsInstance(proto, spartan.SpartanProtocol) |