Clean code
diff --git a/ec2stack/controllers/default.py b/ec2stack/controllers/default.py
index 1f77393..65d1e62 100644
--- a/ec2stack/controllers/default.py
+++ b/ec2stack/controllers/default.py
@@ -26,9 +26,9 @@
def _get_action(action):
actions = {
'AuthorizeSecurityGroupEgress':
- security_groups.authenticate_security_group_egress,
+ security_groups.authenticate_security_group_egress,
'AuthorizeSecurityGroupIngress':
- security_groups.authenticate_security_group_ingress,
+ security_groups.authenticate_security_group_ingress,
'CreateKeyPair': keypairs.create_keypair,
'CreateSecurityGroup': security_groups.create_security_group,
'CreateVolume': volumes.create_volume,
@@ -48,9 +48,9 @@
'RegisterSecretKey': register_secret_key,
'RemoveSecretKey': remove_secret_key,
'RevokeSecurityGroupEgress':
- security_groups.revoke_security_group_egress,
+ security_groups.revoke_security_group_egress,
'RevokeSecurityGroupIngress':
- security_groups.revoke_security_group_ingress,
+ security_groups.revoke_security_group_ingress,
'RunInstances': instances.run_instance,
'StartInstances': instances.start_instance,
'TerminateInstances': instances.terminate_instance,
diff --git a/ec2stack/core.py b/ec2stack/core.py
index 42cfb16..0a3b7fb 100644
--- a/ec2stack/core.py
+++ b/ec2stack/core.py
@@ -7,7 +7,6 @@
class Ec2stackError(Exception):
-
def __init__(self, code, error, message):
self.code = code
self.error = error
diff --git a/ec2stack/errors.py b/ec2stack/errors.py
index 979cfab..ef57812 100644
--- a/ec2stack/errors.py
+++ b/ec2stack/errors.py
@@ -51,6 +51,7 @@
'The specified Disk offering does not exist.'
)
+
def invalid_service_offering_name():
raise Ec2stackError(
'400',
@@ -58,6 +59,7 @@
'The specified Service offering does not exist.'
)
+
def invalid_keypair_name():
raise Ec2stackError(
'400',
diff --git a/ec2stack/helpers.py b/ec2stack/helpers.py
index 34c90b2..08a80d2 100644
--- a/ec2stack/helpers.py
+++ b/ec2stack/helpers.py
@@ -128,9 +128,7 @@
def _valid_signature():
signature = get('Signature')
- print('Signature = ' + str(signature))
generated_signature = generate_signature()
- print('Generated signature = ' + str(generated_signature))
if signature != generated_signature:
raise Ec2stackError(
@@ -140,7 +138,6 @@
)
-
def generate_signature(data=None, method=None, host=None):
if data is None:
data = request.form
diff --git a/ec2stack/providers/cloudstack/instances.py b/ec2stack/providers/cloudstack/instances.py
index 4b1e6d2..19372d8 100644
--- a/ec2stack/providers/cloudstack/instances.py
+++ b/ec2stack/providers/cloudstack/instances.py
@@ -63,8 +63,8 @@
@helpers.authentication_required
def run_instance():
- helpers.require_parameters(['ImageId',
- 'Placement.AvailabilityZone',
+ helpers.require_parameters(['ImageId',
+ 'Placement.AvailabilityZone',
'InstanceType'])
response = _run_instance_request()
return _run_instance_response(response)
@@ -78,7 +78,7 @@
args['zoneid'] = zones.get_zone(availibity_zone_name)['id']
args['serviceofferingid'] = \
- service_offerings.get_service_offering(service_offering_name)['id']
+ service_offerings.get_service_offering(service_offering_name)['id']
args['templateid'] = helpers.get('ImageId')
args['command'] = 'deployVirtualMachine'
diff --git a/ec2stack/providers/cloudstack/service_offerings.py b/ec2stack/providers/cloudstack/service_offerings.py
index 1a1fc9d..55f078e 100644
--- a/ec2stack/providers/cloudstack/service_offerings.py
+++ b/ec2stack/providers/cloudstack/service_offerings.py
@@ -11,4 +11,4 @@
args, 'serviceoffering', errors.invalid_service_offering_name
)
- return response
\ No newline at end of file
+ return response
diff --git a/tests/__init__.py b/tests/__init__.py
index 85bc946..9b3ce11 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -15,7 +15,6 @@
class Ec2StackAppTestCase(FlaskTestCaseMixin, Ec2StackTestCase):
-
def _create_app(self):
return create_app(settings=settings)
diff --git a/tests/controller_tests.py b/tests/controller_tests.py
index b0d73aa..d2b28b5 100644
--- a/tests/controller_tests.py
+++ b/tests/controller_tests.py
@@ -8,7 +8,6 @@
class ControllerTestCase(Ec2StackAppTestCase):
-
def test_invalid_action(self):
data = self.get_example_data()
data['Action'] = 'InvalidAction'
diff --git a/tests/images_tests.py b/tests/images_tests.py
index 4ec01c5..40027ba 100644
--- a/tests/images_tests.py
+++ b/tests/images_tests.py
@@ -8,7 +8,6 @@
class ImagesTestCase(Ec2StackAppTestCase):
-
def test_describe_image(self):
data = self.get_example_data()
data['Action'] = 'DescribeImages'
diff --git a/tests/instances_tests.py b/tests/instances_tests.py
index b5dc549..cddca4b 100644
--- a/tests/instances_tests.py
+++ b/tests/instances_tests.py
@@ -1,16 +1,15 @@
#!/usr/bin/env python
# encoding: utf-8
-import mock
-
import json
+import mock
+
from ec2stack.helpers import read_file, generate_signature
from . import Ec2StackAppTestCase
class InstancesTestCase(Ec2StackAppTestCase):
-
def test_describe_instances(self):
data = self.get_example_data()
data['Action'] = 'DescribeInstances'
@@ -191,8 +190,8 @@
get_service_offering
):
with mock.patch(
- 'ec2stack.providers.cloudstack.zones.get_zone',
- get_zone
+ 'ec2stack.providers.cloudstack.zones.get_zone',
+ get_zone
):
response = self.post(
'/',
diff --git a/tests/keypair_tests.py b/tests/keypair_tests.py
index ee69578..d26b9a4 100644
--- a/tests/keypair_tests.py
+++ b/tests/keypair_tests.py
@@ -10,7 +10,6 @@
class KeyPairTestCase(Ec2StackAppTestCase):
-
def test_create_keypair(self):
data = self.get_example_data()
data['Action'] = 'CreateKeyPair'
diff --git a/tests/password_tests.py b/tests/password_tests.py
index 6294201..1342daf 100644
--- a/tests/password_tests.py
+++ b/tests/password_tests.py
@@ -8,7 +8,6 @@
class PasswordTestCase(Ec2StackAppTestCase):
-
def test_get_password_data(self):
data = self.get_example_data()
data['Action'] = 'GetPasswordData'
diff --git a/tests/security_group_tests.py b/tests/security_group_tests.py
index 74af365..d49cc41 100644
--- a/tests/security_group_tests.py
+++ b/tests/security_group_tests.py
@@ -1,15 +1,15 @@
#!/usr/bin/env python
# encoding: utf-8
-import mock
import json
+import mock
+
from ec2stack.helpers import read_file, generate_signature
from . import Ec2StackAppTestCase
class SecurityGroupTestCase(Ec2StackAppTestCase):
-
def test_create_security_group(self):
data = self.get_example_data()
data['Action'] = 'CreateSecurityGroup'
diff --git a/tests/utils.py b/tests/utils.py
index a247fd8..e6ff58a 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -9,7 +9,6 @@
class FlaskTestCaseMixin(object):
-
@staticmethod
def _html_data(kwargs):
if not kwargs.get('content_type'):
diff --git a/tests/volume_tests.py b/tests/volume_tests.py
index 84208c1..339eccf 100644
--- a/tests/volume_tests.py
+++ b/tests/volume_tests.py
@@ -1,15 +1,15 @@
#!/usr/bin/env python
# encoding: utf-8
-import mock
import json
+import mock
+
from ec2stack.helpers import read_file, generate_signature
from . import Ec2StackAppTestCase
class VolumeTestCase(Ec2StackAppTestCase):
-
def test_describe_volumes(self):
data = self.get_example_data()
data['Action'] = 'DescribeVolumes'
@@ -123,8 +123,8 @@
get_disk_offering
):
with mock.patch(
- 'ec2stack.providers.cloudstack.zones.get_zone',
- get_zone
+ 'ec2stack.providers.cloudstack.zones.get_zone',
+ get_zone
):
response = self.post(
'/',
@@ -154,8 +154,8 @@
with mock.patch('requests.get', get):
with mock.patch(
- 'ec2stack.providers.cloudstack.zones.get_zone',
- get_zone
+ 'ec2stack.providers.cloudstack.zones.get_zone',
+ get_zone
):
response = self.post(
'/',
@@ -184,14 +184,14 @@
))
with mock.patch('requests.get', get_request):
- with mock.patch(
+ with mock.patch(
'ec2stack.providers.cloudstack.zones.get_zone',
get_zone
- ):
- response = self.post(
- '/',
- data=data
- )
+ ):
+ response = self.post(
+ '/',
+ data=data
+ )
self.assert_bad_request(response)
assert 'InvalidSnapshot.NotFound' in response.data
diff --git a/tests/zones_tests.py b/tests/zones_tests.py
index f32e8df..6b494c8 100644
--- a/tests/zones_tests.py
+++ b/tests/zones_tests.py
@@ -8,7 +8,6 @@
class ZonesTestCase(Ec2StackAppTestCase):
-
def test_describe_zone(self):
data = self.get_example_data()
data['Action'] = 'DescribeAvailabilityZones'