示例#1
0
 def test_no_cache(self, should_cache, getter):
     r = requests.Response()
     r.status_code = 200
     r.headers['Docker-Content-Digest'] = 'sha256:asha'
     r._content = b'{"key": "value"}'
     i = Image(f"quay.io/foo/bar:latest", response_cache=None)
     getter.return_value = r
     m = i._get_manifest()
     assert m == r
     getter.assert_called_once_with(
         "https://quay.io/v2/foo/bar/manifests/latest")
     should_cache.assert_not_called()
示例#2
0
 def test_empty_cache_should_not_cache(self, should_cache, getter):
     should_cache.return_value = False
     i = Image(f"quay.io/foo/bar:latest", response_cache={})
     r = requests.Response()
     r.status_code = 200
     r.headers['Docker-Content-Digest'] = 'sha256:asha'
     r._content = b'{"key": "value"}'
     getter.return_value = r
     m = i._get_manifest()
     getter.assert_any_call("https://quay.io/v2/foo/bar/manifests/latest",
                            requests.head)
     getter.assert_any_call("https://quay.io/v2/foo/bar/manifests/latest")
     assert m == r
     assert i.response_cache == {}