01-arcadia.patch 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --- contrib/python/moto/py3/moto/cognitoidp/responses.py (index)
  2. +++ contrib/python/moto/py3/moto/cognitoidp/responses.py (working tree)
  3. @@ -615,10 +615,8 @@ class CognitoIdpResponse(BaseResponse):
  4. class CognitoIdpJsonWebKeyResponse(BaseResponse):
  5. def __init__(self):
  6. - with open(
  7. - os.path.join(os.path.dirname(__file__), "resources/jwks-public.json")
  8. - ) as f:
  9. - self.json_web_key = f.read()
  10. + import pkgutil
  11. + self.json_web_key = pkgutil.get_data(__package__, 'resources/jwks-public.json')
  12. def serve_json_web_key(
  13. self, request, full_url, headers
  14. --- contrib/python/moto/py3/moto/ec2/models/amis.py (index)
  15. +++ contrib/python/moto/py3/moto/ec2/models/amis.py (working tree)
  16. @@ -21,7 +21,7 @@ if "MOTO_AMIS_PATH" in environ:
  17. with open(environ.get("MOTO_AMIS_PATH"), "r", encoding="utf-8") as f:
  18. AMIS = json.load(f)
  19. else:
  20. - AMIS = load_resource(__name__, "../resources/amis.json")
  21. + AMIS = load_resource("moto.ec2", "resources/amis.json")
  22. class Ami(TaggedEC2Resource):
  23. @@ -156,7 +156,7 @@ class AmiBackend:
  24. self.amis[ami_id] = Ami(self, **ami)
  25. try:
  26. latest_amis = load_resource(
  27. - __name__, f"../resources/latest_amis/{self.region_name}.json"
  28. + "moto.ec2", f"resources/latest_amis/{self.region_name}.json"
  29. )
  30. for ami in latest_amis:
  31. ami_id = ami["ami_id"]
  32. --- contrib/python/moto/py3/moto/ec2/models/instance_types.py (index)
  33. +++ contrib/python/moto/py3/moto/ec2/models/instance_types.py (working tree)
  34. @@ -6,19 +6,27 @@ from ..utils import generic_filter
  35. from moto.utilities.utils import load_resource
  36. from ..exceptions import InvalidFilter, InvalidInstanceTypeError
  37. -INSTANCE_TYPES = load_resource(__name__, "../resources/instance_types.json")
  38. +import library.python.resource as _ya_res
  39. +import os
  40. +import json
  41. +
  42. +INSTANCE_TYPES = load_resource("moto.ec2", "resources/instance_types.json")
  43. INSTANCE_FAMILIES = list(set([i.split(".")[0] for i in INSTANCE_TYPES.keys()]))
  44. -root = pathlib.Path(__file__).parent
  45. -offerings_path = "../resources/instance_type_offerings"
  46. +root = pathlib.Path(__file__).parent.parent
  47. +offerings_path = "resources/instance_type_offerings"
  48. INSTANCE_TYPE_OFFERINGS = {}
  49. -for _location_type in listdir(root / offerings_path):
  50. - INSTANCE_TYPE_OFFERINGS[_location_type] = {}
  51. - for _region in listdir(root / offerings_path / _location_type):
  52. - full_path = offerings_path + "/" + _location_type + "/" + _region
  53. - res = load_resource(__name__, full_path)
  54. - for instance in res:
  55. - instance["LocationType"] = _location_type
  56. +for entry in _ya_res.resfs_files(prefix=str(root / offerings_path)):
  57. + rel_path = os.path.relpath(entry, root / offerings_path)
  58. + path_parts = os.path.normpath(rel_path).split(os.path.sep)
  59. + if len(path_parts) != 2:
  60. + continue
  61. + _location_type, _region = path_parts
  62. + if _location_type not in INSTANCE_TYPE_OFFERINGS:
  63. + INSTANCE_TYPE_OFFERINGS[_location_type] = {}
  64. + res = json.loads(_ya_res.find(f"resfs/file/{entry}"))
  65. + for instance in res:
  66. + instance["LocationType"] = _location_type
  67. INSTANCE_TYPE_OFFERINGS[_location_type][_region.replace(".json", "")] = res
  68. --- contrib/python/moto/py3/moto/s3/responses.py (index)
  69. +++ contrib/python/moto/py3/moto/s3/responses.py (working tree)
  70. @@ -283,6 +283,8 @@ class S3Response(BaseResponse):
  71. request.headers.get("Authorization", "")
  72. )
  73. region_name = region_name or DEFAULT_REGION_NAME
  74. + if region_name == "yandex":
  75. + region_name = DEFAULT_REGION_NAME
  76. bucket_name = self.parse_bucket_name_from_url(request, full_url)
  77. if not bucket_name: