31
34
self.version.version_info = {'branch_nick': u'LOCALBRANCH',
32
35
'revision_id': 'LOCALREVISION',
37
self.version.NOVA_PACKAGE = "g9ec3421"
35
39
def test_version_string_is_good(self):
36
40
"""Ensure version string works"""
48
52
self.assertEqual(self.version.canonical_version_string(),
49
53
self.version.version_string())
51
def test_vcs_version_string_is_good(self):
52
"""Ensure uninstalled code generates local """
53
self.assertEqual("LOCALBRANCH:LOCALREVISION",
54
self.version.vcs_version_string())
56
def test_version_string_with_vcs_is_good(self):
55
def test_version_string_with_package_is_good(self):
57
56
"""Ensure uninstalled code get version string"""
58
self.assertEqual("2012.10-LOCALBRANCH:LOCALREVISION",
59
self.version.version_string_with_vcs())
57
self.assertEqual("2012.10-g9ec3421",
58
self.version.version_string_with_package())
60
def test_release_file(self):
61
version.loaded = False
62
real_open = __builtin__.open
63
real_find_file = cfg.CONF.find_file
65
def fake_find_file(self, name):
67
return "/etc/nova/release"
68
return real_find_file(self, name)
70
def fake_open(path, *args, **kwargs):
71
if path == "/etc/nova/release":
73
vendor = ACME Corporation
76
return StringIO.StringIO(data)
78
return real_open(path, *args, **kwargs)
80
self.stubs.Set(__builtin__, 'open', fake_open)
81
self.stubs.Set(cfg.ConfigOpts, 'find_file', fake_find_file)
83
self.assertEqual(version.vendor_string(), "ACME Corporation")
84
self.assertEqual(version.product_string(), "ACME Nova")
85
self.assertEqual(version.package_string(), "1337")