|
9 | 9 |
|
10 | 10 | from docker_registry.core import exceptions |
11 | 11 | import docker_registry.testing as testing |
12 | | -import docker_registry.testing.mock_boto as mock_boto |
13 | | -from docker_registry.drivers import s3 |
14 | 12 |
|
15 | 13 | from docker_registry.testing import mock_boto # noqa |
16 | 14 |
|
@@ -145,31 +143,34 @@ def test_get_tags(self): |
145 | 143 | def test_consistency_latency(self): |
146 | 144 | self.testCount = -1 |
147 | 145 | mockKey = mock_boto.Key() |
| 146 | + |
148 | 147 | def mockExists(): |
149 | 148 | self.testCount += 1 |
150 | 149 | return self.testCount == 1 |
151 | 150 | mockKey.exists = mockExists |
152 | 151 | mockKey.get_contents_as_string = lambda: "Foo bar" |
153 | | - storage = s3.Storage(self.path, self.config) |
154 | | - storage.makeKey = lambda x: mockKey |
| 152 | + self._storage.makeKey = lambda x: mockKey |
155 | 153 | startTime = time.time() |
156 | 154 |
|
157 | | - content = storage.get_content("/FOO") |
| 155 | + content = self._storage.get_content("/FOO") |
158 | 156 |
|
159 | 157 | waitTime = time.time() - startTime |
160 | | - assert waitTime >= 0.1, "Waiting time was less than %sms (actual : %sms)" % (0.1*1000, waitTime*1000) |
161 | | - assert content == "Foo bar", "expected : %s; actual: %s" % ("Foo bar", content) |
| 158 | + assert waitTime >= 0.1, "Waiting time was less than %sms " \ |
| 159 | + "(actual : %sms)" % \ |
| 160 | + (0.1 * 1000, waitTime * 1000) |
| 161 | + assert content == "Foo bar", "expected : %s; actual: %s" % \ |
| 162 | + ("Foo bar", content) |
162 | 163 |
|
163 | 164 | @tools.raises(exceptions.FileNotFoundError) |
164 | 165 | def test_too_many_read_retries(self): |
165 | 166 | self.testCount = -1 |
166 | 167 | mockKey = mock_boto.Key() |
| 168 | + |
167 | 169 | def mockExists(): |
168 | 170 | self.testCount += 1 |
169 | 171 | return self.testCount == 5 |
170 | 172 | mockKey.exists = mockExists |
171 | 173 | mockKey.get_contents_as_string = lambda: "Foo bar" |
172 | | - storage = s3.Storage(self.path, self.config) |
173 | | - storage.makeKey = lambda x: mockKey |
| 174 | + self._storage.makeKey = lambda x: mockKey |
174 | 175 |
|
175 | | - storage.get_content("/FOO") |
| 176 | + self._storage.get_content("/FOO") |
0 commit comments