~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_api.py

  • Committer: Robert Collins
  • Date: 2007-06-26 08:27:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2554.
  • Revision ID: robertc@robertcollins.net-20070626082724-q95taws12ajox2io
Add helpers to get api versions from objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
relevant test modules.
22
22
"""
23
23
 
24
 
import os
25
 
import sys
26
 
 
27
24
import bzrlib
 
25
import bzrlib.api
28
26
from bzrlib.tests import TestCase
29
27
 
30
28
class APITests(TestCase):
35
33
        self.assert_(isinstance(bzrlib.version_string, str))
36
34
        self.assert_(isinstance(bzrlib.version_info, tuple))
37
35
        self.assertEqual(len(bzrlib.version_info), 5)
 
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))