bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2005 Canonical Ltd
|
|
1185.16.128
by Martin Pool
Expose library API version in bzrlib.bzr_version_info |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for library API infrastructure
|
|
18 |
||
19 |
This is specifically for things controlling the interface, such as versioning.
|
|
20 |
Tests for particular parts of the library interface should be in specific
|
|
21 |
relevant test modules.
|
|
22 |
"""
|
|
23 |
||
24 |
import bzrlib |
|
|
2550.2.2
by Robert Collins
Add helpers to get api versions from objects. |
25 |
import bzrlib.api |
|
1185.31.25
by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py |
26 |
from bzrlib.tests import TestCase |
|
1185.16.128
by Martin Pool
Expose library API version in bzrlib.bzr_version_info |
27 |
|
28 |
class APITests(TestCase): |
|
29 |
||
30 |
def test_library_version(self): |
|
31 |
"""Library API version is exposed""" |
|
32 |
self.assert_(isinstance(bzrlib.__version__, str)) |
|
|
1185.16.130
by Martin Pool
Fix tests |
33 |
self.assert_(isinstance(bzrlib.version_string, str)) |
34 |
self.assert_(isinstance(bzrlib.version_info, tuple)) |
|
35 |
self.assertEqual(len(bzrlib.version_info), 5) |
|
|
2550.2.2
by Robert Collins
Add helpers to get api versions from objects. |
36 |
|
37 |
||
38 |
class TrivialObject(object): |
|
39 |
"""This class allows assignment to any attribute.""" |
|
40 |
||
41 |
||
42 |
class TestAPIVersioning(TestCase): |
|
43 |
||
44 |
def test_get_minimum_api_version_reads_api_minimum_version(self): |
|
45 |
an_object = TrivialObject() |
|
46 |
an_object.api_minimum_version = (0, 1, 2) |
|
47 |
self.assertEqual((0, 1, 2), |
|
48 |
bzrlib.api.get_minimum_api_version(an_object)) |
|
49 |
||
50 |
def test_get_minimum_api_version_fallsback_to_bzr_minimum_version(self): |
|
51 |
an_object = TrivialObject() |
|
52 |
self.assertEqual(bzrlib.api_minimum_version, |
|
53 |
bzrlib.api.get_minimum_api_version(an_object)) |
|
54 |
||
55 |
def test_get_current_api_version_reads_api_current_version(self): |
|
56 |
an_object = TrivialObject() |
|
57 |
an_object.api_current_version = (3, 2, 1) |
|
58 |
an_object.version_info = (1, 2, 3, "final", 0) |
|
59 |
self.assertEqual((3, 2, 1), |
|
60 |
bzrlib.api.get_current_api_version(an_object)) |
|
61 |
||
62 |
def test_get_current_api_version_fallsback_to_version_info(self): |
|
63 |
an_object = TrivialObject() |
|
64 |
an_object.version_info = (1, 2, 3, "final", 0) |
|
65 |
self.assertEqual((1, 2, 3), |
|
66 |
bzrlib.api.get_current_api_version(an_object)) |
|
67 |
||
68 |
def test_get_current_api_version_fallsback_to_bzrlib_version_info(self): |
|
69 |
an_object = TrivialObject() |
|
70 |
self.assertEqual(bzrlib.version_info[0:3], |
|
71 |
bzrlib.api.get_current_api_version(an_object)) |