~jaypipes/glance/bug704038

« back to all changes in this revision

Viewing changes to tests/unit/test_stores.py

  • Committer: Tarmac
  • Author(s): Cory Wright
  • Date: 2011-01-10 16:57:03 UTC
  • mfrom: (33.1.1 more-pep8-fixes)
  • Revision ID: tarmac-20110110165703-q33gy3o5kr25byuv
Clean up the rest of Glance's PEP8 problems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
Backend.CHUNKSIZE = 2
29
29
 
 
30
 
30
31
class TestBackend(unittest.TestCase):
 
32
 
31
33
    def setUp(self):
32
34
        """Establish a clean test environment"""
33
35
        self.stubs = stubout.StubOutForTesting()
66
68
 
67
69
    def test_http_get(self):
68
70
        url = "http://netloc/path/to/file.tar.gz"
69
 
        expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s', 
 
71
        expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s',
70
72
                            'ho', 'rt', ' a', 'nd', ' s', 'to', 'ut', '\n']
71
73
        fetcher = get_from_backend(url,
72
74
                                   expected_size=8)
76
78
 
77
79
    def test_https_get(self):
78
80
        url = "https://netloc/path/to/file.tar.gz"
79
 
        expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s', 
 
81
        expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s',
80
82
                            'ho', 'rt', ' a', 'nd', ' s', 'to', 'ut', '\n']
81
83
        fetcher = get_from_backend(url,
82
84
                                   expected_size=8)
93
95
 
94
96
    def test_get(self):
95
97
 
96
 
        swift_uri = "swift://user:password@localhost/container1/file.tar.gz"
97
 
        expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s', 
 
98
        swift_uri = "swift://user:pass@localhost/container1/file.tar.gz"
 
99
        expected_returns = ['I ', 'am', ' a', ' t', 'ea', 'po', 't,', ' s',
98
100
                            'ho', 'rt', ' a', 'nd', ' s', 'to', 'ut', '\n']
99
101
 
100
102
        fetcher = get_from_backend(swift_uri,
109
111
 
110
112
        swift_url = "swift://localhost/container1/file.tar.gz"
111
113
 
112
 
        self.assertRaises(BackendException, get_from_backend, 
 
114
        self.assertRaises(BackendException, get_from_backend,
113
115
                          swift_url, expected_size=21)
114
116
 
115
117
    def test_url_parsing(self):
116
118
 
117
 
        swift_uri = "swift://user:password@localhost/v1.0/container1/file.tar.gz"
 
119
        swift_uri = "swift://user:pass@localhost/v1.0/container1/file.tar.gz"
118
120
 
119
121
        parsed_uri = urlparse.urlparse(swift_uri)
120
122
 
122
124
            SwiftBackend._parse_swift_tokens(parsed_uri)
123
125
 
124
126
        self.assertEqual(user, 'user')
125
 
        self.assertEqual(key, 'password')
 
127
        self.assertEqual(key, 'pass')
126
128
        self.assertEqual(authurl, 'https://localhost/v1.0')
127
129
        self.assertEqual(container, 'container1')
128
130
        self.assertEqual(obj, 'file.tar.gz')