Esempio n. 1
0
    def test_methods_structure(self):
        """Test that VERSIONED_METHODS gets data as expected."""
        self.assertEqual(0, len(microversion.VERSIONED_METHODS))
        fully_qualified_method = microversion._fully_qualified_name(handler)
        microversion.version_handler('1.1', '1.10')(handler)
        microversion.version_handler('2.0')(handler)

        methods_data = microversion.VERSIONED_METHODS[fully_qualified_method]

        stored_method_data = methods_data[-1]
        self.assertEqual(2, len(methods_data))
        self.assertEqual(microversion.Version(1, 1), stored_method_data[0])
        self.assertEqual(microversion.Version(1, 10), stored_method_data[1])
        self.assertEqual(handler, stored_method_data[2])
        self.assertEqual(microversion.Version(2, 0), methods_data[0][0])
def _environ(path='/moo', method='GET'):
    return {
        'PATH_INFO':
        path,
        'REQUEST_METHOD':
        method,
        'SERVER_NAME':
        'example.com',
        'SERVER_PORT':
        '80',
        'wsgi.url_scheme':
        'http',
        # The microversion version value is not used, but it
        # needs to be set to avoid a KeyError.
        microversion.MICROVERSION_ENVIRON:
        microversion.Version(1, 12),
    }