Tests for ``SeparateBodyFileCache``
| 142 | |
| 143 | |
| 144 | class TestSeparateBodyFileCache(FileCacheTestsMixin): |
| 145 | """ |
| 146 | Tests for ``SeparateBodyFileCache`` |
| 147 | """ |
| 148 | |
| 149 | FileCacheClass = SeparateBodyFileCache |
| 150 | |
| 151 | def test_body_actually_stored_separately(self, sess): |
| 152 | """ |
| 153 | Body is stored and can be retrieved from the SeparateBodyFileCache, with assurances |
| 154 | it's actually being loaded from separate file than metadata. |
| 155 | """ |
| 156 | url = self.url + "cache_60" |
| 157 | response = sess.get(url) |
| 158 | body = response.content |
| 159 | response2 = sess.get(url) |
| 160 | assert response2.from_cache |
| 161 | assert response2.content == body |
| 162 | |
| 163 | # OK now let's violate some abstraction boundaries to make sure body |
| 164 | # actually came from separate file. |
| 165 | with open(self.cache._fn(url), "rb") as f: |
| 166 | assert body not in f.read() |
| 167 | with open(self.cache._fn(url) + ".body", "rb") as f: |
| 168 | assert body == f.read() |
| 169 | with open(self.cache._fn(url) + ".body", "wb") as f: |
| 170 | f.write(b"CORRUPTED") |
| 171 | response2 = sess.get(url) |
| 172 | assert response2.from_cache |
| 173 | assert response2.content == b"CORRUPTED" |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…