~notmyname/swift/deslogging

« back to all changes in this revision

Viewing changes to test/unit/common/test_init.py

  • Committer: Tarmac
  • Author(s): Soren Hansen
  • Date: 2011-05-27 13:32:07 UTC
  • mfrom: (300.1.4 1.4.0-versioning)
  • Revision ID: tarmac-20110527133207-1ajnpsfmfoxqk7kv
Add a __canonical_version__ attribute to the swift module. This is only the numbered part of the version string, no "-dev" or similar suffixes.

Add a couple of unit tests to make sure __version__ and __canonical_version__ are generated correctly and to ensure __canonical_version__ never accidentally has anything other than numbers and points in it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2010-2011 OpenStack, LLC.
 
2
#
 
3
# Licensed under the Apache License, Version 2.0 (the "License");
 
4
# you may not use this file except in compliance with the License.
 
5
# You may obtain a copy of the License at
 
6
#
 
7
#    http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
# Unless required by applicable law or agreed to in writing, software
 
10
# distributed under the License is distributed on an "AS IS" BASIS,
 
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
12
# implied.
 
13
# See the License for the specific language governing permissions and
 
14
# limitations under the License.
 
15
 
 
16
import re
 
17
import unittest
 
18
import swift
 
19
 
 
20
class TestVersioning(unittest.TestCase):
 
21
    def test_canonical_version_is_clean(self):
 
22
        """Ensure that a non-clean canonical_version never happens"""
 
23
        pattern = re.compile('^\d+(\.\d+)*$')
 
24
        self.assertTrue(pattern.match(swift.__canonical_version__) is not None)
 
25
 
 
26
    def test_canonical_version_equals_version_for_final(self):
 
27
        version = swift.Version('7.8.9', True)
 
28
        self.assertEquals(version.pretty_version, '7.8.9')
 
29
        self.assertEquals(version.canonical_version, '7.8.9')
 
30
 
 
31
    def test_version_has_dev_suffix_for_non_final(self):
 
32
        version = swift.Version('7.8.9', False)
 
33
        self.assertEquals(version.pretty_version, '7.8.9-dev')
 
34
        self.assertEquals(version.canonical_version, '7.8.9')
 
35
 
 
36
if __name__ == '__main__':
 
37
    unittest.main()