removed local junk from example code, included real fixtures from actual API


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4bde5af3
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4bde5af3
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4bde5af3

Branch: refs/heads/trunk
Commit: 4bde5af3e2ead0e81763805eadeacc0451f334f2
Parents: 9507a63
Author: anthony-shaw <[email protected]>
Authored: Sun Jan 3 20:50:43 2016 +1100
Committer: anthony-shaw <[email protected]>
Committed: Sun Jan 3 20:50:43 2016 +1100

----------------------------------------------------------------------
 .../container/ecs/instantiate_driver.py         | 10 +--
 .../container/fixtures/ecs/describetasks.json   | 75 +++++++++-----------
 libcloud/test/container/test_ecs.py             | 10 +--
 3 files changed, 42 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/4bde5af3/docs/examples/container/ecs/instantiate_driver.py
----------------------------------------------------------------------
diff --git a/docs/examples/container/ecs/instantiate_driver.py 
b/docs/examples/container/ecs/instantiate_driver.py
index a854745..19400db 100644
--- a/docs/examples/container/ecs/instantiate_driver.py
+++ b/docs/examples/container/ecs/instantiate_driver.py
@@ -1,12 +1,12 @@
 from libcloud.container.types import Provider
 from libcloud.container.providers import get_driver
 
-import libcloud.security
-libcloud.security.VERIFY_SSL_CERT = False
-
 cls = get_driver(Provider.ECS)
 
 conn = cls(access_id='AKIAI7OR4GWEEPRIFBBA', 
secret='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', region='ap-southeast-2')
-conn.connection.set_http_proxy(proxy_url='http://localhost:8888')
 
-print(conn.list_containers())
+for container in conn.list_containers():
+    print(container.name)
+
+for cluster in conn.list_clusters():
+    print(cluster.name)

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4bde5af3/libcloud/test/container/fixtures/ecs/describetasks.json
----------------------------------------------------------------------
diff --git a/libcloud/test/container/fixtures/ecs/describetasks.json 
b/libcloud/test/container/fixtures/ecs/describetasks.json
index d8e0624..1dd5f1b 100644
--- a/libcloud/test/container/fixtures/ecs/describetasks.json
+++ b/libcloud/test/container/fixtures/ecs/describetasks.json
@@ -1,46 +1,35 @@
 {
-  "failures": [],
-  "tasks": [
-    {
-      "clusterArn": "arn:aws:ecs:us-east-1:012345678910:cluster/default",
-      "containerInstanceArn": 
"arn:aws:ecs:us-east-1:012345678910:container-instance/84818520-995f-4d94-9d70-7714bacc2953",
-      "containers": [
-        {
-          "containerArn": 
"arn:aws:ecs:us-east-1:012345678910:container/76c980a8-2454-4a9c-acc4-9eb103117273",
-          "lastStatus": "RUNNING",
-          "name": "mysql",
-          "networkBindings": [],
-          "taskArn": 
"arn:aws:ecs:us-east-1:012345678910:task/c09f0188-7f87-4b0f-bfc3-16296622b6fe"
-        },
-        {
-          "containerArn": 
"arn:aws:ecs:us-east-1:012345678910:container/e3c69b8f-f15e-4d33-8093-282c2d2325e9",
-          "lastStatus": "RUNNING",
-          "name": "wordpress",
-          "networkBindings": [
-            {
-              "bindIP": "0.0.0.0",
-              "containerPort": 80,
-              "hostPort": 80
-            }
-          ],
-          "taskArn": 
"arn:aws:ecs:us-east-1:012345678910:task/c09f0188-7f87-4b0f-bfc3-16296622b6fe"
+    "failures": [],
+    "tasks": [{
+            "clusterArn": 
"arn:aws:ecs:ap-southeast-2:647433528374:cluster/default",
+            "containerInstanceArn": 
"arn:aws:ecs:ap-southeast-2:647433528374:container-instance/13b83f4b-d557-48a6-a4d7-2b0e8068e62b",
+            "containers": [{
+                    "containerArn": 
"arn:aws:ecs:ap-southeast-2:647433528374:container/d56d4e2c-9804-42a7-9f2a-6029cb50d4a2",
+                    "lastStatus": "RUNNING",
+                    "name": "simple-app",
+                    "networkBindings": [{
+                            "bindIP": "0.0.0.0",
+                            "containerPort": 80,
+                            "hostPort": 80,
+                            "protocol": "tcp"
+                        }
+                    ],
+                    "taskArn": 
"arn:aws:ecs:ap-southeast-2:647433528374:task/c15bcab8-39e6-4c28-a47d-27b433269e5c"
+                }
+            ],
+            "createdAt": 1.451468104403E9,
+            "desiredStatus": "RUNNING",
+            "lastStatus": "RUNNING",
+            "overrides": {
+                "containerOverrides": [{
+                        "name": "simple-app"
+                    }
+                ]
+            },
+            "startedAt": 1.45146812139E9,
+            "startedBy": "ecs-svc/9223370585386692588",
+            "taskArn": 
"arn:aws:ecs:ap-southeast-2:647433528374:task/c15bcab8-39e6-4c28-a47d-27b433269e5c",
+            "taskDefinitionArn": 
"arn:aws:ecs:ap-southeast-2:647433528374:task-definition/console-sample-app-static:1"
         }
-      ],
-      "desiredStatus": "RUNNING",
-      "lastStatus": "RUNNING",
-      "overrides": {
-        "containerOverrides": [
-          {
-            "name": "mysql"
-          },
-          {
-            "name": "wordpress"
-          }
-        ]
-      },
-      "startedBy": "ecs-svc/9223370606521064774",
-      "taskArn": 
"arn:aws:ecs:us-east-1:012345678910:task/c09f0188-7f87-4b0f-bfc3-16296622b6fe",
-      "taskDefinitionArn": 
"arn:aws:ecs:us-east-1:012345678910:task-definition/hello_world:10"
-    }
-  ]
+    ]
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4bde5af3/libcloud/test/container/test_ecs.py
----------------------------------------------------------------------
diff --git a/libcloud/test/container/test_ecs.py 
b/libcloud/test/container/test_ecs.py
index 86b715e..f0e8937 100644
--- a/libcloud/test/container/test_ecs.py
+++ b/libcloud/test/container/test_ecs.py
@@ -55,12 +55,12 @@ class ElasticContainerDriverTestCase(unittest.TestCase):
 
     def test_list_containers(self):
         containers = self.driver.list_containers()
-        self.assertEqual(len(containers), 2)
+        self.assertEqual(len(containers), 1)
 
     def test_list_containers_for_cluster(self):
         cluster = self.driver.list_clusters()[0]
         containers = self.driver.list_containers(cluster=cluster)
-        self.assertEqual(len(containers), 2)
+        self.assertEqual(len(containers), 1)
 
     def test_deploy_container(self):
         container = self.driver.deploy_container(
@@ -79,9 +79,9 @@ class ElasticContainerDriverTestCase(unittest.TestCase):
         container = self.driver.get_container(
             
'arn:aws:ecs:us-east-1:012345678910:container/76c980a8-2454-4a9c-acc4-9eb103117273'
         )
-        self.assertEqual(container.id, 
'arn:aws:ecs:us-east-1:012345678910:container/76c980a8-2454-4a9c-acc4-9eb103117273')
-        self.assertEqual(container.name, 'mysql')
-        self.assertEqual(container.image.name, 'mysql')
+        self.assertEqual(container.id, 
'arn:aws:ecs:ap-southeast-2:647433528374:container/d56d4e2c-9804-42a7-9f2a-6029cb50d4a2')
+        self.assertEqual(container.name, 'simple-app')
+        self.assertEqual(container.image.name, 'simple-app')
 
     def test_start_container(self):
         container = self.driver.start_container(

Reply via email to