spulec/moto — pull request #224 by joekiller (2014-10-05 02:47:24+00:00)
Title: Tags and Keep Blank Values when parsing url.

Core
====
Amazon treats blank values as empty strings, ie http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html

* Update BaseResponse to keep blank values of keys when parsing the url.

Tags
====

refactored tags to be able to apply a dictionary of tags as specified in http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html

* create_tags and delete tags validates resource ids
* create_tags ensures that resources exist prior to tagging
* fixed delete tag rendering unncessary template
* Update describe_tags to use filters from querystring

Exceptions
======

* Added InvalidID exception used by CreateTags and DeleteTags per http://docs.aws.amazon.com/AWSEC2/latest/APIReference/api-error-codes.html#InvalidID
* Added TagLimitExceeded per http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html

Models
=====

* Added validate resource ids method which will throw a InvalidID exception if the resource_id form is incorrect
* Renamed TaggedEC2Instance object to TaggedEC2Resource, updated all inheritance references.
* Added TagBackend create_tags method
* Updated TagBackend create_tags to throw InvalidParameterValueErrorTagNull if a CreateTag key doesn't include a value
* Updated TagBackend create_tags to throw TagLimitExceeded
* removed TagBackend create_tag and delete_tag functions
* Added TagBackend delete_tags method
* Updated delete_tags method to allow key/value delete per http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteTags.html
* Updated SpotInstanceRequest to allow filter_name 'spot-instance-request-id'
* Enhanced EC2 Model to allow for checking of if a resource exists based on the resource_id. This is necessary because tag creations verify that a resource exists prior to performing any action.
* Updated create_tags method to check if len(tags) > 10 and raise TagLimitExceeded even if the resource doesn't have any tags.
* Updated TaggedEC2Resource to pass in a proper filter dictionary to describe_tags
* Updated Instance get_tags to pass in proper filter dictionary to describe_tags
* Updated TagBackend to properly filter response based on filter dictionary

EC2 Utils
======

* Added EC2_RESOURCE_PREFIXES to help with parsing prefixes in resource_ids
* Updates random_[resource] functions to use EC2_RESOURCE_PREFIXES dictionary
* Updated tags_from_query_string to return a dictionary of tag keys and tag values.
* Added get_prefix method to help with determining resource types from EC2 resource_ids
* Added is_valid_resource_id method to determine if a resource_id is valid for EC2 resources
* Renamed EC2_RESOURCE_PREFIXES dictionary to EC2_RESOURCE_TO_PREFIX
* Added EC2_PREFIX_TO_RESOURCE dictionary which is EC2_RESOURCE_TO_PREFIX inverted.
* Added simple_aws_filter_to_re method for converting AWS wildcard syntax keys to python regular expression matches

Test Tags
======

* Renamed various tag test names to be more relevent
* Added test to raise InvalidParameterValue when a tag key is None
* Added test_tag_limit_exceeded
* Added test_get_all_tags_resource_id_filter to test get_all_tags using resource-id filter
* Added test_get_all_tags_resource_type_filter to test get_all_tags using resource-type filter
* Added test_get_all_tags_key_filter to test get_all_tags using key filter
* Added test_get_all_tags_value_filter to test get_all_tags using value filter