示例#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.0', '1.9')(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(1.0, stored_method_data[0])
        self.assertEqual(1.9, stored_method_data[1])
        self.assertEqual(handler, stored_method_data[2])
        self.assertEqual(2.0, methods_data[0][0])
示例#2
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])
示例#3
0
    def test_faked_non_intersection(self):
        microversion.version_handler('1.0', '1.8')(handler)
        microversion.version_handler('1.9', '2.0')(handler)

        for method_info in microversion.VERSIONED_METHODS.values():
            self.assertFalse(self._check_intersection(method_info))
示例#4
0
 def test_version_handler_tuple_exception(self):
     self.assertRaises(TypeError,
                       microversion.version_handler((1, 1)),
                       handler)
示例#5
0
 def test_version_handler_nan_exception(self):
     self.assertRaises(TypeError,
                       microversion.version_handler('cow'),
                       handler)
示例#6
0
 def test_version_handler_float_exception(self):
     self.assertRaises(TypeError,
                       microversion.version_handler(1.1),
                       handler)
示例#7
0
    def test_faked_non_intersection(self):
        microversion.version_handler('1.0', '1.8')(handler)
        microversion.version_handler('1.9', '2.0')(handler)

        for method_info in microversion.VERSIONED_METHODS.values():
            self.assertFalse(self._check_intersection(method_info))
示例#8
0
 def test_version_handler_tuple_exception(self):
     self.assertRaises(AttributeError, microversion.version_handler((1, 1)),
                       handler)
示例#9
0
 def test_version_handler_nan_exception(self):
     self.assertRaises(TypeError, microversion.version_handler('cow'),
                       handler)
示例#10
0
 def test_version_handler_float_exception(self):
     self.assertRaises(AttributeError, microversion.version_handler(1.1),
                       handler)