'Test ControllerMetaclass works inheriting from non base class.'

def test_versions_inheritance_internals_of_non_base_controller(self):

    def _get_str_version(version):
        return ('%s.%s' % (version._ver_major, version._ver_minor))
    def assert_method_equal(expected, observed):
        if six.PY2:
            expected = expected.im_func
        self.assertEqual(expected, observed)
    class ControllerParent(wsgi.Controller, ):
        @wsgi.Controller.api_version('3.0')
        def index(self, req):
            pass
    class Controller(wsgi.Controller, ):
        @wsgi.Controller.api_version('2.0')
        def index(self, req):
            pass
    class ControllerChild(ControllerParent, ):
        @wsgi.Controller.api_version('3.1')
        def index(self, req):
            pass
        @wsgi.Controller.api_version('3.2')
        def new_method(self, req):
            pass
    self.assertSetEqual({'index'}, set(ControllerParent.versioned_methods))
    self.assertEqual(1, len(ControllerParent.versioned_methods['index']))
    index = ControllerParent.versioned_methods['index'][0]
    assert_method_equal(ControllerParent.index, index.func)
    self.assertEqual('index', index.name)
    self.assertEqual('3.0', _get_str_version(index.start_version))
    self.assertEqual('None.None', _get_str_version(index.end_version))
    self.assertSetEqual({'index'}, set(Controller.versioned_methods))
    self.assertEqual(1, len(Controller.versioned_methods['index']))
    index = Controller.versioned_methods['index'][0]
    assert_method_equal(Controller.index, index.func)
    self.assertEqual('index', index.name)
    self.assertEqual('2.0', _get_str_version(index.start_version))
    self.assertEqual('None.None', _get_str_version(index.end_version))
    self.assertSetEqual({'index', 'new_method'}, set(ControllerChild.versioned_methods))
    self.assertEqual(2, len(ControllerChild.versioned_methods['index']))
    index = ControllerChild.versioned_methods['index'][0]
    assert_method_equal(ControllerChild.index, index.func)
    self.assertEqual('index', index.name)
    self.assertEqual('3.1', _get_str_version(index.start_version))
    self.assertEqual('None.None', _get_str_version(index.end_version))
    index = ControllerChild.versioned_methods['index'][1]
    assert_method_equal(ControllerParent.index, index.func)
    self.assertEqual('index', index.name)
    self.assertEqual('3.0', _get_str_version(index.start_version))
    self.assertEqual('None.None', _get_str_version(index.end_version))
    self.assertEqual(1, len(ControllerChild.versioned_methods['new_method']))
    new_method = ControllerChild.versioned_methods['new_method'][0]
    assert_method_equal(ControllerChild.new_method, new_method.func)
    self.assertEqual('new_method', new_method.name)
    self.assertEqual('3.2', _get_str_version(new_method.start_version))
    self.assertEqual('None.None', _get_str_version(new_method.end_version))
