Skip to content

Commit

Permalink
Prep release 4.0.13 (#5813)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Jan 4, 2023
1 parent d68fb04 commit 2e08c32
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 47 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
Moto Changelog
==============


4.0.13
-----
Docker Digest for 4.0.13: <autopopulateddigest>

New Methods:
* EC2:
* get_password_data()
* Sagemaker:
* update_pipeline()
* SecretsManager:
* cancel_rotate_secret()

Miscellaneous:
* CloudWatch: put_metric_data() now supports the StatisticValues-parameter
* CognitoIDP: sign_out() now also invalidates the AccessToken
* IAM: get_account_authorization_details() now returns the Tags-attribute
* IOT: create_keys_and_certificate() now creates valid certificates, instead of random data


4.0.12
-----
Docker Digest for 4.0.12: _sha256:06916d3f310c68fd445468f06d6d4ae6f855e7f2b80e007a90bd11eeb421b5ed_
Expand Down
22 changes: 15 additions & 7 deletions IMPLEMENTATION_COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,7 @@
- [X] get_managed_prefix_list_entries
- [ ] get_network_insights_access_scope_analysis_findings
- [ ] get_network_insights_access_scope_content
- [x] get_password_data
- [X] get_password_data
- [ ] get_reserved_instances_exchange_quote
- [ ] get_serial_console_access_status
- [ ] get_spot_placement_scores
Expand Down Expand Up @@ -2731,7 +2731,7 @@

## emr
<details>
<summary>42% implemented</summary>
<summary>41% implemented</summary>

- [ ] add_instance_fleet
- [X] add_instance_groups
Expand All @@ -2753,6 +2753,7 @@
- [ ] describe_studio
- [ ] get_auto_termination_policy
- [ ] get_block_public_access_configuration
- [ ] get_cluster_session_credentials
- [ ] get_managed_scaling_policy
- [ ] get_studio_session_mapping
- [X] list_bootstrap_actions
Expand Down Expand Up @@ -3924,14 +3925,16 @@

## kinesisvideo
<details>
<summary>20% implemented</summary>
<summary>17% implemented</summary>

- [ ] create_signaling_channel
- [X] create_stream
- [ ] delete_signaling_channel
- [X] delete_stream
- [ ] describe_edge_configuration
- [ ] describe_image_generation_configuration
- [ ] describe_mapped_resource_configuration
- [ ] describe_media_storage_configuration
- [ ] describe_notification_configuration
- [ ] describe_signaling_channel
- [X] describe_stream
Expand All @@ -3948,6 +3951,7 @@
- [ ] untag_stream
- [ ] update_data_retention
- [ ] update_image_generation_configuration
- [ ] update_media_storage_configuration
- [ ] update_notification_configuration
- [ ] update_signaling_channel
- [ ] update_stream
Expand Down Expand Up @@ -5766,6 +5770,7 @@
- [ ] import_hub_content
- [ ] list_actions
- [ ] list_algorithms
- [ ] list_aliases
- [ ] list_app_image_configs
- [ ] list_apps
- [ ] list_artifacts
Expand Down Expand Up @@ -5876,14 +5881,15 @@
- [ ] update_feature_metadata
- [ ] update_hub
- [ ] update_image
- [ ] update_image_version
- [ ] update_inference_experiment
- [ ] update_model_card
- [ ] update_model_package
- [ ] update_monitoring_alert
- [ ] update_monitoring_schedule
- [ ] update_notebook_instance
- [ ] update_notebook_instance_lifecycle_config
- [ ] update_pipeline
- [X] update_pipeline
- [ ] update_pipeline_execution
- [ ] update_project
- [ ] update_space
Expand Down Expand Up @@ -5913,9 +5919,9 @@

## secretsmanager
<details>
<summary>68% implemented</summary>
<summary>72% implemented</summary>

- [ ] cancel_rotate_secret
- [X] cancel_rotate_secret
- [X] create_secret
- [ ] delete_resource_policy
- [X] delete_secret
Expand Down Expand Up @@ -6721,6 +6727,7 @@
- keyspaces
- kinesis-video-media
- kinesis-video-signaling
- kinesis-video-webrtc-storage
- kinesisanalytics
- kinesisanalyticsv2
- lakeformation
Expand All @@ -6729,6 +6736,7 @@
- lexv2-models
- lexv2-runtime
- license-manager
- license-manager-linux-subscriptions
- license-manager-user-subscriptions
- lightsail
- location
Expand Down Expand Up @@ -6835,4 +6843,4 @@
- workspaces
- workspaces-web
- xray
</details>
</details>
76 changes: 38 additions & 38 deletions docs/docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ For example, we have the following code we want to test:

import boto3

class MyModel(object):
class MyModel:
def __init__(self, name, value):
self.name = name
self.value = value

def save(self):
s3 = boto3.client('s3', region_name='us-east-1')
s3.put_object(Bucket='mybucket', Key=self.name, Body=self.value)
s3 = boto3.client("s3", region_name="us-east-1")
s3.put_object(Bucket="mybucket", Key=self.name, Body=self.value)

There are several ways to verify that the value will be persisted successfully.

Expand All @@ -57,17 +57,17 @@ With a decorator wrapping, all the calls to S3 are automatically mocked out.

@mock_s3
def test_my_model_save():
conn = boto3.resource('s3', region_name='us-east-1')
conn = boto3.resource("s3", region_name="us-east-1")
# We need to create the bucket since this is all in Moto's 'virtual' AWS account
conn.create_bucket(Bucket='mybucket')
conn.create_bucket(Bucket="mybucket")

model_instance = MyModel('steve', 'is awesome')
model_instance = MyModel("steve", "is awesome")
model_instance.save()

body = conn.Object('mybucket', 'steve').get()[
'Body'].read().decode("utf-8")
body = conn.Object("mybucket", "steve").get()[
"Body"].read().decode("utf-8")

assert body == 'is awesome'
assert body == "is awesome"

Context manager
~~~~~~~~~~~~~~~
Expand All @@ -78,16 +78,16 @@ Same as the Decorator, every call inside the ``with`` statement is mocked out.

def test_my_model_save():
with mock_s3():
conn = boto3.resource('s3', region_name='us-east-1')
conn.create_bucket(Bucket='mybucket')
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="mybucket")

model_instance = MyModel('steve', 'is awesome')
model_instance = MyModel("steve", "is awesome")
model_instance.save()

body = conn.Object('mybucket', 'steve').get()[
'Body'].read().decode("utf-8")
body = conn.Object("mybucket", "steve").get()[
"Body"].read().decode("utf-8")

assert body == 'is awesome'
assert body == "is awesome"

Raw
~~~
Expand All @@ -100,16 +100,16 @@ You can also start and stop the mocking manually.
mock = mock_s3()
mock.start()

conn = boto3.resource('s3', region_name='us-east-1')
conn.create_bucket(Bucket='mybucket')
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="mybucket")

model_instance = MyModel('steve', 'is awesome')
model_instance = MyModel("steve", "is awesome")
model_instance.save()

body = conn.Object('mybucket', 'steve').get()[
'Body'].read().decode("utf-8")
body = conn.Object("mybucket", "steve").get()[
"Body"].read().decode("utf-8")

assert body == 'is awesome'
assert body == "is awesome"

mock.stop()

Expand All @@ -125,18 +125,18 @@ If you use `unittest`_ to run tests, and you want to use `moto` inside `setUp`,
import boto3

def func_to_test(bucket_name, key, content):
s3 = boto3.resource('s3')
s3 = boto3.resource("s3")
object = s3.Object(bucket_name, key)
object.put(Body=content)

class MyTest(unittest.TestCase):
mock_s3 = mock_s3()
bucket_name = 'test-bucket'
bucket_name = "test-bucket"
def setUp(self):
self.mock_s3.start()

# you can use boto3.client('s3') if you prefer
s3 = boto3.resource('s3')
# you can use boto3.client("s3") if you prefer
s3 = boto3.resource("s3")
bucket = s3.Bucket(self.bucket_name)
bucket.create()

Expand All @@ -145,15 +145,15 @@ If you use `unittest`_ to run tests, and you want to use `moto` inside `setUp`,

def test(self):
content = b"abc"
key = '/path/to/obj'
key = "/path/to/obj"

# run the file which uploads to S3
func_to_test(self.bucket_name, key, content)

# check the file was uploaded as expected
s3 = boto3.resource('s3')
s3 = boto3.resource("s3")
object = s3.Object(self.bucket_name, key)
actual = object.get()['Body'].read()
actual = object.get()["Body"].read()
self.assertEqual(actual, content)

Class Decorator
Expand Down Expand Up @@ -231,19 +231,19 @@ Here is an example:

.. sourcecode:: python

@pytest.fixture(scope='function')
@pytest.fixture(scope="function")
def aws_credentials():
"""Mocked AWS Credentials for moto."""
os.environ['AWS_ACCESS_KEY_ID'] = 'testing'
os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing'
os.environ['AWS_SECURITY_TOKEN'] = 'testing'
os.environ['AWS_SESSION_TOKEN'] = 'testing'
os.environ['AWS_DEFAULT_REGION'] = 'us-east-1'
os.environ["AWS_ACCESS_KEY_ID"] = "testing"
os.environ["AWS_SECRET_ACCESS_KEY"] = "testing"
os.environ["AWS_SECURITY_TOKEN"] = "testing"
os.environ["AWS_SESSION_TOKEN"] = "testing"
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"

@pytest.fixture(scope='function')
@pytest.fixture(scope="function")
def s3(aws_credentials):
with mock_s3():
yield boto3.client('s3', region_name='us-east-1')
yield boto3.client("s3", region_name="us-east-1")


In the code sample above, all of the AWS/mocked fixtures take in a parameter of `aws_credentials`,
Expand All @@ -260,8 +260,8 @@ Next, once you need to do anything with the mocked AWS environment, do something
s3.create_bucket(Bucket="somebucket")

result = s3.list_buckets()
assert len(result['Buckets']) == 1
assert result['Buckets'][0]['Name'] == 'somebucket'
assert len(result["Buckets"]) == 1
assert result["Buckets"][0]["Name"] == "somebucket"

What about those pesky imports
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/services/ec2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ ec2
- [X] get_managed_prefix_list_entries
- [ ] get_network_insights_access_scope_analysis_findings
- [ ] get_network_insights_access_scope_content
- [x] get_password_data
- [X] get_password_data
- [ ] get_reserved_instances_exchange_quote
- [ ] get_serial_console_access_status
- [ ] get_spot_placement_scores
Expand Down
1 change: 1 addition & 0 deletions docs/docs/services/emr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ emr
- [ ] describe_studio
- [ ] get_auto_termination_policy
- [ ] get_block_public_access_configuration
- [ ] get_cluster_session_credentials
- [ ] get_managed_scaling_policy
- [ ] get_studio_session_mapping
- [X] list_bootstrap_actions
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/services/kinesisvideo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ kinesisvideo

- [ ] describe_edge_configuration
- [ ] describe_image_generation_configuration
- [ ] describe_mapped_resource_configuration
- [ ] describe_media_storage_configuration
- [ ] describe_notification_configuration
- [ ] describe_signaling_channel
- [X] describe_stream
Expand All @@ -55,6 +57,7 @@ kinesisvideo
- [ ] untag_stream
- [ ] update_data_retention
- [ ] update_image_generation_configuration
- [ ] update_media_storage_configuration
- [ ] update_notification_configuration
- [ ] update_signaling_channel
- [ ] update_stream
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/services/sagemaker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ sagemaker
- [ ] import_hub_content
- [ ] list_actions
- [ ] list_algorithms
- [ ] list_aliases
- [ ] list_app_image_configs
- [ ] list_apps
- [ ] list_artifacts
Expand Down Expand Up @@ -306,6 +307,7 @@ sagemaker
- [ ] update_feature_metadata
- [ ] update_hub
- [ ] update_image
- [ ] update_image_version
- [ ] update_inference_experiment
- [ ] update_model_card
- [ ] update_model_package
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/services/secretsmanager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ secretsmanager

|start-h3| Implemented features for this service |end-h3|

- [ ] cancel_rotate_secret
- [X] cancel_rotate_secret
- [X] create_secret
- [ ] delete_resource_policy
- [X] delete_secret
Expand Down
2 changes: 2 additions & 0 deletions moto/iotdata/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def delete_thing_shadow(self):

def publish(self):
topic = self.path.split("/topics/")[-1]
# a uri parameter containing forward slashes is not correctly url encoded when we're running in server mode.
# https://github.com/pallets/flask/issues/900
topic = unquote(topic) if "%" in topic else topic
self.iotdata_backend.publish(topic=topic, payload=self.body)
return json.dumps(dict())

0 comments on commit 2e08c32

Please sign in to comment.