from __future__ import absolute_import

import unittest

import servy.server


def fn():
    pass


class Simple(object):
    @classmethod
    def fn():
        pass


class Complex(servy.server.Container):
    simple = Simple
    fn = fn


class ServerInitiation(unittest.TestCase):
    def test_explicit(self):
        server = servy.server.Server(
            fn=fn,
        )
        self.assertEqual(server.procedures, {
            'fn': fn,
        })

    def test_explicit_with_junk(self):
        server = servy.server.Server(
            junk=type,
        )
        self.assertEqual(server.procedures, {})

    def test_decorator_simple_container(self):
        Server = servy.server.Server(Simple)
        self.assertEqual(Server.procedures, {
            'fn': Simple.fn,
        })

    def test_decorator_simple_non_container(self):
        @servy.server.Server
        class Server(object):
            simple = Simple

        self.assertEqual(Server.procedures, {})

@@ -958,28 +958,240 @@
 qual(Server.procedures, %7B%7D)%0A
+%0A    def test_decorator_complex(self):%0A        @servy.server.Server%0A        class Server(object):%0A            c = Complex%0A%0A        self.assertEqual(Server.procedures, %7B%0A            'c.fn': Complex.fn,%0A        %7D)%0A

extend tests for initiation