from __future__ import unicode_literals, print_function
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_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)


@@ -764,16 +764,333 @@
 None%7D)%0A%0A
+    def test_websocket(self):%0A        o = server_tap.Options()%0A        o.parseOptions(%5B%22--websocket=tcp:4004%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, %22websocket-url%22: None%7D)%0A%0A
     def 

test for websocket option-parsing