69
70
an_object = TrivialObject()
70
71
self.assertEqual(bzrlib.version_info[0:3],
71
72
bzrlib.api.get_current_api_version(an_object))
74
def test_require_api_wanted_is_minimum_is_ok(self):
75
an_object = TrivialObject()
76
an_object.api_minimum_version = (1, 2, 3)
77
an_object.api_current_version = (4, 5, 6)
78
bzrlib.api.require_api(an_object, (1, 2, 3))
80
def test_require_api_wanted_is_current_is_ok(self):
81
an_object = TrivialObject()
82
an_object.api_minimum_version = (1, 2, 3)
83
an_object.api_current_version = (4, 5, 6)
84
bzrlib.api.require_api(an_object, (4, 5, 6))
86
def test_require_api_wanted_is_above_minimum_is_ok(self):
87
an_object = TrivialObject()
88
an_object.api_minimum_version = (1, 2, 3)
89
an_object.api_current_version = (4, 5, 6)
90
bzrlib.api.require_api(an_object, (1, 2, 4))
92
def test_require_api_wanted_is_below_current_is_ok(self):
93
an_object = TrivialObject()
94
an_object.api_minimum_version = (1, 2, 3)
95
an_object.api_current_version = (4, 5, 6)
96
bzrlib.api.require_api(an_object, (4, 5, 5))
98
def test_require_api_wanted_is_below_minimum_raises(self):
99
an_object = TrivialObject()
100
an_object.api_minimum_version = (1, 2, 3)
101
an_object.api_current_version = (4, 5, 6)
102
err = self.assertRaises(IncompatibleAPI,
103
bzrlib.api.require_api, an_object, (1, 2, 2))
104
self.assertEqual(err.api, an_object)
105
self.assertEqual(err.wanted, (1, 2, 2))
106
self.assertEqual(err.minimum, (1, 2, 3))
107
self.assertEqual(err.current, (4, 5, 6))
109
def test_require_api_wanted_is_above_current_raises(self):
110
an_object = TrivialObject()
111
an_object.api_minimum_version = (1, 2, 3)
112
an_object.api_current_version = (4, 5, 6)
113
err = self.assertRaises(IncompatibleAPI,
114
bzrlib.api.require_api, an_object, (4, 5, 7))
115
self.assertEqual(err.api, an_object)
116
self.assertEqual(err.wanted, (4, 5, 7))
117
self.assertEqual(err.minimum, (1, 2, 3))
118
self.assertEqual(err.current, (4, 5, 6))