Compare commits

..

No commits in common. "master" and "d01bd59ea933e8b72d74e57af25086aed7bd74e9" have entirely different histories.

8 changed files with 102 additions and 118 deletions

0
moto/ec2/responses/amis.py Normal file → Executable file
View file

0
moto/iam/models.py Normal file → Executable file
View file

View file

@ -12,7 +12,6 @@ from datetime import datetime
from boto3 import Session from boto3 import Session
from moto.core import BaseBackend, BaseModel from moto.core import BaseBackend, BaseModel
from moto.utilities.utils import random_string
from .exceptions import ( from .exceptions import (
CertificateStateException, CertificateStateException,
DeleteConflictException, DeleteConflictException,
@ -22,6 +21,7 @@ from .exceptions import (
VersionConflictException, VersionConflictException,
ResourceAlreadyExistsException, ResourceAlreadyExistsException,
) )
from moto.utilities.utils import random_string
class FakeThing(BaseModel): class FakeThing(BaseModel):
@ -144,8 +144,7 @@ class FakeCertificate(BaseModel):
self.transfer_data = {} self.transfer_data = {}
self.creation_date = time.time() self.creation_date = time.time()
self.last_modified_date = self.creation_date self.last_modified_date = self.creation_date
self.validity_not_before = time.time() - 86400
self.validity_not_after = time.time() + 86400
self.ca_certificate_id = None self.ca_certificate_id = None
self.ca_certificate_pem = ca_certificate_pem self.ca_certificate_pem = ca_certificate_pem
if ca_certificate_pem: if ca_certificate_pem:
@ -175,10 +174,6 @@ class FakeCertificate(BaseModel):
"ownedBy": self.owner, "ownedBy": self.owner,
"creationDate": self.creation_date, "creationDate": self.creation_date,
"lastModifiedDate": self.last_modified_date, "lastModifiedDate": self.last_modified_date,
"validity": {
"notBefore": self.validity_not_before,
"notAfter": self.validity_not_after,
},
"transferData": self.transfer_data, "transferData": self.transfer_data,
} }
@ -583,7 +578,7 @@ class IoTBackend(BaseBackend):
) )
else: else:
token = int(token) token = int(token)
things = filtered_things[token: token + max_results] things = filtered_things[token : token + max_results]
next_token = ( next_token = (
str(token + max_results) str(token + max_results)
if len(filtered_things) > token + max_results if len(filtered_things) > token + max_results
@ -1214,7 +1209,7 @@ class IoTBackend(BaseBackend):
next_token = str(max_results) if len(filtered_jobs) > max_results else None next_token = str(max_results) if len(filtered_jobs) > max_results else None
else: else:
token = int(token) token = int(token)
jobs = filtered_jobs[token: token + max_results] jobs = filtered_jobs[token : token + max_results]
next_token = ( next_token = (
str(token + max_results) str(token + max_results)
if len(filtered_jobs) > token + max_results if len(filtered_jobs) > token + max_results
@ -1293,7 +1288,7 @@ class IoTBackend(BaseBackend):
next_token = str(max_results) if len(job_executions) > max_results else None next_token = str(max_results) if len(job_executions) > max_results else None
else: else:
token = int(token) token = int(token)
job_executions = job_executions[token: token + max_results] job_executions = job_executions[token : token + max_results]
next_token = ( next_token = (
str(token + max_results) str(token + max_results)
if len(job_executions) > token + max_results if len(job_executions) > token + max_results
@ -1325,7 +1320,7 @@ class IoTBackend(BaseBackend):
next_token = str(max_results) if len(job_executions) > max_results else None next_token = str(max_results) if len(job_executions) > max_results else None
else: else:
token = int(token) token = int(token)
job_executions = job_executions[token: token + max_results] job_executions = job_executions[token : token + max_results]
next_token = ( next_token = (
str(token + max_results) str(token + max_results)
if len(job_executions) > token + max_results if len(job_executions) > token + max_results

View file

@ -37,9 +37,7 @@ def main():
for region in regions: for region in regions:
for location_type in TYPES: for location_type in TYPES:
ec2 = boto3.client("ec2", region_name=region) ec2 = boto3.client("ec2", region_name=region)
dest = os.path.join( dest = os.path.join(root_dir, "{0}/{1}/{2}.json".format(PATH, location_type, region))
root_dir, "{0}/{1}/{2}.json".format(PATH, location_type, region)
)
try: try:
instances = [] instances = []
offerings = ec2.describe_instance_type_offerings( offerings = ec2.describe_instance_type_offerings(
@ -49,7 +47,8 @@ def main():
next_token = offerings.get("NextToken", "") next_token = offerings.get("NextToken", "")
while next_token: while next_token:
offerings = ec2.describe_instance_type_offerings( offerings = ec2.describe_instance_type_offerings(
LocationType=location_type, NextToken=next_token LocationType=location_type,
NextToken=next_token
) )
instances.extend(offerings["InstanceTypeOfferings"]) instances.extend(offerings["InstanceTypeOfferings"])
next_token = offerings.get("NextToken", None) next_token = offerings.get("NextToken", None)

View file

@ -26,7 +26,9 @@ def main():
instances.extend(offerings["InstanceTypes"]) instances.extend(offerings["InstanceTypes"])
next_token = offerings.get("NextToken", "") next_token = offerings.get("NextToken", "")
while next_token: while next_token:
offerings = ec2.describe_instance_types(NextToken=next_token) offerings = ec2.describe_instance_types(
NextToken=next_token
)
instances.extend(offerings["InstanceTypes"]) instances.extend(offerings["InstanceTypes"])
next_token = offerings.get("NextToken", None) next_token = offerings.get("NextToken", None)
except Exception: except Exception:
@ -37,7 +39,7 @@ def main():
print("Parsing data") print("Parsing data")
result = {} result = {}
for instance in instances: for instance in instances:
result[instance.get("InstanceType")] = instance result[instance.get('InstanceType')] = instance
root_dir = ( root_dir = (
subprocess.check_output(["git", "rev-parse", "--show-toplevel"]) subprocess.check_output(["git", "rev-parse", "--show-toplevel"])

View file

@ -104,19 +104,11 @@ all_server_deps = all_extra_deps + ["flask", "flask-cors"]
# i.e. even those without extra dependencies. # i.e. even those without extra dependencies.
# Would be good for future-compatibility, I guess. # Would be good for future-compatibility, I guess.
extras_per_service = { extras_per_service = {
"apigateway": [ "apigateway": [_dep_python_jose_py2, _dep_python_jose_py3, _dep_python_jose_ecdsa_pin],
_dep_python_jose_py2,
_dep_python_jose_py3,
_dep_python_jose_ecdsa_pin,
],
"awslambda": [_dep_docker], "awslambda": [_dep_docker],
"batch": [_dep_docker], "batch": [_dep_docker],
"cloudformation": [_dep_docker, _dep_PyYAML, _dep_cfn_lint, _dep_decorator], "cloudformation": [_dep_docker, _dep_PyYAML, _dep_cfn_lint, _dep_decorator],
"cognitoidp": [ "cognitoidp": [_dep_python_jose_py2, _dep_python_jose_py3, _dep_python_jose_ecdsa_pin],
_dep_python_jose_py2,
_dep_python_jose_py3,
_dep_python_jose_ecdsa_pin,
],
"dynamodb2": [_dep_docker], "dynamodb2": [_dep_docker],
"dynamodbstreams": [_dep_docker], "dynamodbstreams": [_dep_docker],
"ec2": [_dep_docker, _dep_sshpubkeys_py2, _dep_sshpubkeys_py3], "ec2": [_dep_docker, _dep_sshpubkeys_py2, _dep_sshpubkeys_py3],
@ -153,7 +145,11 @@ setup(
author="Steve Pulec", author="Steve Pulec",
author_email="spulec@gmail.com", author_email="spulec@gmail.com",
url="https://github.com/spulec/moto", url="https://github.com/spulec/moto",
entry_points={"console_scripts": ["moto_server = moto.server:main",],}, entry_points={
"console_scripts": [
"moto_server = moto.server:main",
],
},
packages=find_packages(exclude=("tests", "tests.*")), packages=find_packages(exclude=("tests", "tests.*")),
install_requires=install_requires, install_requires=install_requires,
extras_require=extras_require, extras_require=extras_require,
@ -171,5 +167,7 @@ setup(
"License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: Apache Software License",
"Topic :: Software Development :: Testing", "Topic :: Software Development :: Testing",
], ],
project_urls={"Documentation": "http://docs.getmoto.org/en/latest/",}, project_urls={
"Documentation": "http://docs.getmoto.org/en/latest/",
},
) )

View file

@ -538,10 +538,6 @@ def test_certs():
cert_desc.should.have.key("certificateArn").which.should_not.be.none cert_desc.should.have.key("certificateArn").which.should_not.be.none
cert_desc.should.have.key("certificateId").which.should_not.be.none cert_desc.should.have.key("certificateId").which.should_not.be.none
cert_desc.should.have.key("certificatePem").which.should_not.be.none cert_desc.should.have.key("certificatePem").which.should_not.be.none
cert_desc.should.have.key("validity").which.should_not.be.none
validity = cert_desc["validity"]
validity.should.have.key("notBefore").which.should_not.be.none
validity.should.have.key("notAfter").which.should_not.be.none
cert_desc.should.have.key("status").which.should.equal("ACTIVE") cert_desc.should.have.key("status").which.should.equal("ACTIVE")
cert_pem = cert_desc["certificatePem"] cert_pem = cert_desc["certificatePem"]
@ -1023,7 +1019,7 @@ def test_delete_thing_group():
group_name_1a = "my-group-name-1a" group_name_1a = "my-group-name-1a"
group_name_2a = "my-group-name-2a" group_name_2a = "my-group-name-2a"
tree_dict = { tree_dict = {
group_name_1a: {group_name_2a: {}, }, group_name_1a: {group_name_2a: {},},
} }
group_catalog = generate_thing_group_tree(client, tree_dict) group_catalog = generate_thing_group_tree(client, tree_dict)

View file

@ -54,7 +54,7 @@ def migrate_version(target_file, new_version):
regex = r"['\"](.*)['\"]" regex = r"['\"](.*)['\"]"
migrate_source_attribute( migrate_source_attribute(
"__version__", "__version__",
'"{new_version}"'.format(new_version=new_version), "\"{new_version}\"".format(new_version=new_version),
target_file, target_file,
regex, regex,
) )
@ -84,9 +84,7 @@ def prerelease_version():
assert ( assert (
initpy_ver > ver initpy_ver > ver
), "the moto/__init__.py version should be newer than the last tagged release." ), "the moto/__init__.py version should be newer than the last tagged release."
return "{}.{}.{}.dev{}".format( return "{}.{}.{}.dev{}".format(initpy_ver.major, initpy_ver.minor, initpy_ver.micro, commits_since)
initpy_ver.major, initpy_ver.minor, initpy_ver.micro, commits_since
)
def read(*parts): def read(*parts):
@ -118,9 +116,7 @@ def increase_patch_version(old_version):
:param old_version: 2.0.1 :param old_version: 2.0.1
:return: 2.0.2.dev :return: 2.0.2.dev
""" """
return "{}.{}.{}.dev".format( return "{}.{}.{}.dev".format(old_version.major, old_version.minor, old_version.micro + 1)
old_version.major, old_version.minor, old_version.micro + 1
)
def release_version_correct(): def release_version_correct():
@ -158,7 +154,5 @@ if __name__ == "__main__":
initpy = os.path.abspath("moto/__init__.py") initpy = os.path.abspath("moto/__init__.py")
migrate_version(initpy, new_version) migrate_version(initpy, new_version)
else: else:
print( print("Invalid usage. Supply 0 or 1 arguments. "
"Invalid usage. Supply 0 or 1 arguments. " "Argument can be either a version '1.2.3' or 'patch' if you want to increase the patch-version (1.2.3 -> 1.2.4.dev)")
"Argument can be either a version '1.2.3' or 'patch' if you want to increase the patch-version (1.2.3 -> 1.2.4.dev)"
)