LEFT | RIGHT |
1 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 1 # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
2 # Copyright (C) 2009 Canonical Ltd | 2 # Copyright (C) 2009 Canonical Ltd |
3 # Copyright (C) 2009 Duncan McGreggor <oubiwann@adytum.us> | 3 # Copyright (C) 2009 Duncan McGreggor <oubiwann@adytum.us> |
4 # Licenced under the txaws licence available at /LICENSE in the txaws source. | 4 # Licenced under the txaws licence available at /LICENSE in the txaws source. |
5 | 5 |
6 from datetime import datetime | 6 from datetime import datetime |
7 import os | 7 import os |
8 | 8 |
9 from twisted.internet import reactor | 9 from twisted.internet import reactor |
10 from twisted.internet.defer import succeed, fail | 10 from twisted.internet.defer import succeed, fail |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 def check_result(id): | 589 def check_result(id): |
590 self.assertEquals(id, "sg-1a2b3c4d") | 590 self.assertEquals(id, "sg-1a2b3c4d") |
591 | 591 |
592 creds = AWSCredentials("foo", "bar") | 592 creds = AWSCredentials("foo", "bar") |
593 ec2 = client.EC2Client(creds, query_factory=StubQuery) | 593 ec2 = client.EC2Client(creds, query_factory=StubQuery) |
594 d = ec2.create_security_group( | 594 d = ec2.create_security_group( |
595 "WebServers", | 595 "WebServers", |
596 "The group for the web server farm.") | 596 "The group for the web server farm.") |
597 return d.addCallback(check_result) | 597 return d.addCallback(check_result) |
598 | 598 |
| 599 def test_create_security_group_with_VPC(self): |
| 600 class StubQuery(object): |
| 601 |
| 602 def __init__(stub, action="", creds=None, endpoint=None, |
| 603 other_params={}): |
| 604 self.assertEqual(action, "CreateSecurityGroup") |
| 605 self.assertEqual(creds.access_key, "foo") |
| 606 self.assertEqual(creds.secret_key, "bar") |
| 607 self.assertEqual(other_params, { |
| 608 "GroupName": "WebServers", |
| 609 "GroupDescription": "The group for the web server farm.", |
| 610 "VpcId": "vpc-a4f2", |
| 611 }) |
| 612 |
| 613 def submit(self): |
| 614 return succeed(payload.sample_create_security_group) |
| 615 |
| 616 def check_result(id): |
| 617 self.assertEquals(id, "sg-1a2b3c4d") |
| 618 |
| 619 creds = AWSCredentials("foo", "bar") |
| 620 ec2 = client.EC2Client(creds, query_factory=StubQuery) |
| 621 d = ec2.create_security_group( |
| 622 "WebServers", |
| 623 "The group for the web server farm.", |
| 624 "vpc-a4f2") |
| 625 return d.addCallback(check_result) |
| 626 |
599 def test_delete_security_group_using_name(self): | 627 def test_delete_security_group_using_name(self): |
600 """ | 628 """ |
601 L{EC2Client.delete_security_group} returns a C{Deferred} that | 629 L{EC2Client.delete_security_group} returns a C{Deferred} that |
602 eventually fires with a true value, indicating the success of the | 630 eventually fires with a true value, indicating the success of the |
603 operation. | 631 operation. |
604 """ | 632 """ |
605 class StubQuery(object): | 633 class StubQuery(object): |
606 | 634 |
607 def __init__(stub, action="", creds=None, endpoint=None, | 635 def __init__(stub, action="", creds=None, endpoint=None, |
608 other_params={}): | 636 other_params={}): |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 https://launchpad.net/bugs/862680 | 2119 https://launchpad.net/bugs/862680 |
2092 """ | 2120 """ |
2093 | 2121 |
2094 nova_xml = ( | 2122 nova_xml = ( |
2095 '<?xml version="1.0" ?><TerminateInstancesResponse ' | 2123 '<?xml version="1.0" ?><TerminateInstancesResponse ' |
2096 'xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"><requestId>' | 2124 'xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"><requestId>' |
2097 '4fe6643d-2346-4add-adb7-a1f61f37c043</requestId>' | 2125 '4fe6643d-2346-4add-adb7-a1f61f37c043</requestId>' |
2098 '<return>true</return></TerminateInstancesResponse>') | 2126 '<return>true</return></TerminateInstancesResponse>') |
2099 nova_response = self.parser.terminate_instances(nova_xml) | 2127 nova_response = self.parser.terminate_instances(nova_xml) |
2100 self.assertEquals([], nova_response) | 2128 self.assertEquals([], nova_response) |
LEFT | RIGHT |