~ubuntu-branches/ubuntu/trusty/swift/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-04-02 09:06:48 UTC
  • mfrom: (1.2.18)
  • Revision ID: package-import@ubuntu.com-20130402090648-dq5fc3iy8hfoq9fq
Tags: 1.8.0~rc2-0ubuntu1
New usptream release candidate for grizzly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
 
128
128
    def setUp(self):
129
129
        utils.HASH_PATH_SUFFIX = 'endcap'
 
130
        utils.HASH_PATH_PREFIX = 'startcap'
130
131
 
131
132
    def test_normalize_timestamp(self):
132
133
        """ Test swift.common.utils.normalize_timestamp """
626
627
        self.assert_('127.0.0.1' in myips)
627
628
 
628
629
    def test_hash_path(self):
 
630
        _prefix = utils.HASH_PATH_PREFIX 
 
631
        utils.HASH_PATH_PREFIX = ''
629
632
        # Yes, these tests are deliberately very fragile. We want to make sure
630
633
        # that if someones changes the results hash_path produces, they know it
631
 
        self.assertEquals(utils.hash_path('a'),
632
 
                          '1c84525acb02107ea475dcd3d09c2c58')
633
 
        self.assertEquals(utils.hash_path('a', 'c'),
634
 
                          '33379ecb053aa5c9e356c68997cbb59e')
635
 
        self.assertEquals(utils.hash_path('a', 'c', 'o'),
636
 
                          '06fbf0b514e5199dfc4e00f42eb5ea83')
637
 
        self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=False),
638
 
                          '06fbf0b514e5199dfc4e00f42eb5ea83')
639
 
        self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=True),
640
 
                          '\x06\xfb\xf0\xb5\x14\xe5\x19\x9d\xfcN'
641
 
                          '\x00\xf4.\xb5\xea\x83')
642
 
        self.assertRaises(ValueError, utils.hash_path, 'a', object='o')
 
634
        try:
 
635
            self.assertEquals(utils.hash_path('a'),
 
636
                              '1c84525acb02107ea475dcd3d09c2c58')
 
637
            self.assertEquals(utils.hash_path('a', 'c'),
 
638
                              '33379ecb053aa5c9e356c68997cbb59e')
 
639
            self.assertEquals(utils.hash_path('a', 'c', 'o'),
 
640
                              '06fbf0b514e5199dfc4e00f42eb5ea83')
 
641
            self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=False),
 
642
                              '06fbf0b514e5199dfc4e00f42eb5ea83')
 
643
            self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=True),
 
644
                              '\x06\xfb\xf0\xb5\x14\xe5\x19\x9d\xfcN'
 
645
                              '\x00\xf4.\xb5\xea\x83')
 
646
            self.assertRaises(ValueError, utils.hash_path, 'a', object='o')
 
647
            utils.HASH_PATH_PREFIX = 'abcdef'
 
648
            self.assertEquals(utils.hash_path('a', 'c', 'o', raw_digest=False),
 
649
                              '363f9b535bfb7d17a43a46a358afca0e')
 
650
        finally:
 
651
            utils.HASH_PATH_PREFIX = _prefix
643
652
 
644
653
    def test_load_libc_function(self):
645
654
        self.assert_(callable(