from twisted.trial import unittest
from .. import server_tap

PORT = "tcp:4001:interface=\:\:"

class Config(unittest.TestCase):
    def test_defaults(self):
        o = server_tap.Options()
        o.parseOptions([])
        self.assertEqual(o, {"blur-usage": None, "log-fd": None,
                             "usage-db": None, "port": PORT,
                             "websocket": None, "websocket-url": None})
    def test_blur(self):
        o = server_tap.Options()
        o.parseOptions(["--blur-usage=60"])
        self.assertEqual(o, {"blur-usage": 60, "log-fd": None,
                             "usage-db": None, "port": PORT,
                             "websocket": None, "websocket-url": None})

    def test_websocket(self):
        o = server_tap.Options()
        o.parseOptions(["--websocket=tcp:4004"])
        self.assertEqual(o, {"blur-usage": None, "log-fd": None,
                             "usage-db": None, "port": PORT,
                             "websocket": "tcp:4004", "websocket-url": None})

    def test_string(self):
        o = server_tap.Options()
        s = str(o)
        self.assertIn("This plugin sets up a 'Transit Relay'", s)
        self.assertIn("--blur-usage=", s)
        self.assertIn("blur timestamps and data sizes in logs", s)


@@ -1017,32 +1017,434 @@
 t-url%22: None%7D)%0A%0A
+    def test_websocket_url(self):%0A        o = server_tap.Options()%0A        o.parseOptions(%5B%22--websocket=tcp:4004%22, %22--websocket-url=ws://example.com/%22%5D)%0A        self.assertEqual(o, %7B%22blur-usage%22: None, %22log-fd%22: None,%0A                             %22usage-db%22: None, %22port%22: PORT,%0A                             %22websocket%22: %22tcp:4004%22,%0A                             %22websocket-url%22: %22ws://example.com/%22%7D)%0A%0A
     def test_str

test --websocket-url option too