This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/test/test_swift.py
2016-01-15 15:35:04 -05:00

42 lines
1.1 KiB
Python

import unittest
from storage.swift import SwiftStorage
from mock import MagicMock
class TestSwiftStorage(SwiftStorage):
def __init__(self, *args, **kwargs):
super(TestSwiftStorage, self).__init__(*args, **kwargs)
self._connection = MagicMock()
def _get_connection(self):
return self._connection
class SwiftTests(unittest.TestCase):
base_args = {
'metric_queue': None,
'swift_container': 'container-name',
'storage_path': '/basepath',
'auth_url': 'https://auth.com',
'swift_user': 'root',
'swift_password': 'password',
}
def test_fixed_path_concat(self):
swift = TestSwiftStorage(**self.base_args)
swift.exists('object/path')
swift._get_connection().head_object.assert_called_with('container-name', 'basepath/object/path')
def test_simple_path_concat(self):
simple_concat_args = dict(self.base_args)
simple_concat_args['simple_path_concat'] = True
swift = TestSwiftStorage(**simple_concat_args)
swift.exists('object/path')
swift._get_connection().head_object.assert_called_with('container-name', 'basepathobject/path')
if __name__ == '__main__':
unittest.main()