Merge "Move autoscaling update policy to functional"
diff --git a/common/remote_client.py b/common/remote_client.py
index 3b48545..5365ceb 100644
--- a/common/remote_client.py
+++ b/common/remote_client.py
@@ -12,13 +12,14 @@
 
 import cStringIO
 import logging
-import paramiko
 import re
 import select
-import six
 import socket
 import time
 
+import paramiko
+import six
+
 from heat_integrationtests.common import exceptions
 
 LOG = logging.getLogger(__name__)
diff --git a/common/test.py b/common/test.py
index 57083fd..4c96567 100644
--- a/common/test.py
+++ b/common/test.py
@@ -10,19 +10,19 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import fixtures
 import logging
 import os
 import random
 import re
-import six
 import subprocess
-import testscenarios
-import testtools
 import time
 
+import fixtures
 from heatclient import exc as heat_exceptions
 from oslo.utils import timeutils
+import six
+import testscenarios
+import testtools
 
 from heat_integrationtests.common import clients
 from heat_integrationtests.common import config
diff --git a/functional/test_remote_stack.py b/functional/test_remote_stack.py
index d9eec79..1b6f961 100644
--- a/functional/test_remote_stack.py
+++ b/functional/test_remote_stack.py
@@ -11,10 +11,11 @@
 #    under the License.
 
 import logging
+
+from heatclient import exc
 import six
 
 from heat_integrationtests.common import test
-from heatclient import exc
 
 LOG = logging.getLogger(__name__)
 
diff --git a/functional/test_resource_group.py b/functional/test_resource_group.py
index 8ccddd8..dba6f5c 100644
--- a/functional/test_resource_group.py
+++ b/functional/test_resource_group.py
@@ -10,9 +10,11 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import six
+import json
 
 from heatclient import exc
+import six
+import yaml
 
 from heat_integrationtests.common import test
 
@@ -129,7 +131,7 @@
             return output_value
         # verify that the resources in resource group are identically
         # configured, resource names and outputs are appropriate.
-        stack_identifier = self.stack_create('create_stack', template=template)
+        stack_identifier = self.stack_create(template=template)
         self.assertEqual({u'random_group': u'OS::Heat::ResourceGroup'},
                          self.list_resources(stack_identifier))
 
@@ -145,7 +147,7 @@
 
     def test_update_increase_decrease_count(self):
         # create stack with resource group count 2
-        stack_identifier = self.stack_create('update_stack', template=template)
+        stack_identifier = self.stack_create(template=template)
         self.assertEqual({u'random_group': u'OS::Heat::ResourceGroup'},
                          self.list_resources(stack_identifier))
         # verify that the resource group has 2 resources
@@ -162,3 +164,74 @@
         self.update_stack(stack_identifier, update_template)
         # verify that the resource group has 3 resources
         self._validate_resources(stack_identifier, 3)
+
+
+class ResourceGroupAdoptTest(test.HeatIntegrationTest):
+    """Prove that we can do resource group adopt."""
+
+    main_template = '''
+heat_template_version: "2013-05-23"
+resources:
+  group1:
+    type: OS::Heat::ResourceGroup
+    properties:
+      count: 2
+      resource_def:
+        type: OS::Heat::RandomString
+outputs:
+  test0:
+    value: {get_attr: [group1, resource.0.value]}
+  test1:
+    value: {get_attr: [group1, resource.1.value]}
+'''
+
+    def setUp(self):
+        super(ResourceGroupAdoptTest, self).setUp()
+        self.client = self.orchestration_client
+
+    def _yaml_to_json(self, yaml_templ):
+        return yaml.load(yaml_templ)
+
+    def test_adopt(self):
+        data = {
+            "resources": {
+                "group1": {
+                    "status": "COMPLETE",
+                    "name": "group1",
+                    "resource_data": {},
+                    "metadata": {},
+                    "resource_id": "test-group1-id",
+                    "action": "CREATE",
+                    "type": "OS::Heat::ResourceGroup",
+                    "resources": {
+                        "0": {
+                            "status": "COMPLETE",
+                            "name": "0",
+                            "resource_data": {"value": "goopie"},
+                            "resource_id": "ID-0",
+                            "action": "CREATE",
+                            "type": "OS::Heat::RandomString",
+                            "metadata": {}
+                        },
+                        "1": {
+                            "status": "COMPLETE",
+                            "name": "1",
+                            "resource_data": {"value": "different"},
+                            "resource_id": "ID-1",
+                            "action": "CREATE",
+                            "type": "OS::Heat::RandomString",
+                            "metadata": {}
+                        }
+                    }
+                }
+            },
+            "environment": {"parameters": {}},
+            "template": yaml.load(self.main_template)
+        }
+        stack_identifier = self.stack_adopt(
+            adopt_data=json.dumps(data))
+
+        self.assert_resource_is_a_stack(stack_identifier, 'group1')
+        stack = self.client.stacks.get(stack_identifier)
+        self.assertEqual('goopie', self._stack_output(stack, 'test0'))
+        self.assertEqual('different', self._stack_output(stack, 'test1'))
diff --git a/functional/test_template_resource.py b/functional/test_template_resource.py
index 828ff74..6b3fabb 100644
--- a/functional/test_template_resource.py
+++ b/functional/test_template_resource.py
@@ -12,6 +12,7 @@
 
 import json
 import logging
+
 import yaml
 
 from heat_integrationtests.common import test
diff --git a/scenario/test_volumes.py b/scenario/test_volumes.py
index fe9ec03..841a091 100644
--- a/scenario/test_volumes.py
+++ b/scenario/test_volumes.py
@@ -11,10 +11,10 @@
 #    under the License.
 
 import logging
-import six
-from testtools import testcase
 
 from cinderclient import exceptions as cinder_exceptions
+import six
+from testtools import testcase
 
 from heat_integrationtests.common import exceptions
 from heat_integrationtests.common import test