Example #1
0
 def test_parse_describe_security_groups_response(self):
     """Parse a DescribeSecurityGroupsResponse payload."""
     schema = self.schemas["DescribeSecurityGroupsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = ("<DescribeSecurityGroupsResponse xmlns=\"%s\">"
            "<requestId>3ef0aa1d-57dd-4272</requestId>"
            "<securityGroupInfo>"
            "<item>"
            "<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>"
            "<groupName>WebServers</groupName>"
            "<groupDescription>Web</groupDescription>"
            "<ipPermissions>"
            "<item>"
            "<ipProtocol>tcp</ipProtocol>"
            "<fromPort>80</fromPort>"
            "<toPort>80</toPort>"
            "<groups/>"
            "<ipRanges>"
            "<item>"
            "<cidrIp>0.0.0.0/0</cidrIp>"
            "</item>"
            "</ipRanges>"
            "</item>"
            "</ipPermissions>"
            "</item>"
            "</securityGroupInfo>"
            "</DescribeSecurityGroupsResponse>" % xmlns)
     root = etree.fromstring(xml)
     response = schema.create(root)
     self.assertEqual("3ef0aa1d-57dd-4272", response.requestId)
     self.assertEqual("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM",
                      response.securityGroupInfo[0].ownerId)
     self.assertEqual("WebServers", response.securityGroupInfo[0].groupName)
     self.assertEqual("Web", response.securityGroupInfo[0].groupDescription)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #2
0
 def test_modify_describe_key_pairs_response(self):
     """Modify a DescribeKeyPairsResponse payload."""
     schema = self.schemas["DescribeKeyPairsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = ("<DescribeKeyPairsResponse xmlns=\"%s\">"
            "<requestId>3ef0aa1d-57dd-4272</requestId>"
            "<keySet>"
            "<item>"
            "<keyName>europe-key</keyName>"
            "<keyFingerprint>94:88:29:60:cf</keyFingerprint>"
            "</item>"
            "</keySet>"
            "</DescribeKeyPairsResponse>" % xmlns)
     root = etree.fromstring(xml)
     response = schema.create(root)
     response.keySet[0].keyName = "new-key"
     xml = ("<DescribeKeyPairsResponse xmlns=\"%s\">"
            "<requestId>3ef0aa1d-57dd-4272</requestId>"
            "<keySet>"
            "<item>"
            "<keyName>new-key</keyName>"
            "<keyFingerprint>94:88:29:60:cf</keyFingerprint>"
            "</item>"
            "</keySet>"
            "</DescribeKeyPairsResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #3
0
 def test_modify_describe_key_pairs_response(self):
     """Modify a DescribeKeyPairsResponse payload."""
     schema = self.schemas["DescribeKeyPairsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = ("<DescribeKeyPairsResponse xmlns=\"%s\">"
            "<requestId>3ef0aa1d-57dd-4272</requestId>"
            "<keySet>"
            "<item>"
            "<keyName>europe-key</keyName>"
            "<keyFingerprint>94:88:29:60:cf</keyFingerprint>"
            "</item>"
            "</keySet>"
            "</DescribeKeyPairsResponse>" % xmlns)
     root = etree.fromstring(xml)
     response = schema.create(root)
     response.keySet[0].keyName = "new-key"
     xml = ("<DescribeKeyPairsResponse xmlns=\"%s\">"
            "<requestId>3ef0aa1d-57dd-4272</requestId>"
            "<keySet>"
            "<item>"
            "<keyName>new-key</keyName>"
            "<keyFingerprint>94:88:29:60:cf</keyFingerprint>"
            "</item>"
            "</keySet>"
            "</DescribeKeyPairsResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #4
0
 def test_parse_describe_security_groups_response(self):
     """Parse a DescribeSecurityGroupsResponse payload."""
     schema = self.schemas["DescribeSecurityGroupsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = ("<DescribeSecurityGroupsResponse xmlns=\"%s\">"
            "<requestId>3ef0aa1d-57dd-4272</requestId>"
            "<securityGroupInfo>"
            "<item>"
            "<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>"
            "<groupName>WebServers</groupName>"
            "<groupDescription>Web</groupDescription>"
            "<ipPermissions>"
            "<item>"
            "<ipProtocol>tcp</ipProtocol>"
            "<fromPort>80</fromPort>"
            "<toPort>80</toPort>"
            "<groups/>"
            "<ipRanges>"
            "<item>"
            "<cidrIp>0.0.0.0/0</cidrIp>"
            "</item>"
            "</ipRanges>"
            "</item>"
            "</ipPermissions>"
            "</item>"
            "</securityGroupInfo>"
            "</DescribeSecurityGroupsResponse>" % xmlns)
     root = etree.fromstring(xml)
     response = schema.create(root)
     self.assertEqual("3ef0aa1d-57dd-4272", response.requestId)
     self.assertEqual("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM",
                      response.securityGroupInfo[0].ownerId)
     self.assertEqual("WebServers", response.securityGroupInfo[0].groupName)
     self.assertEqual("Web", response.securityGroupInfo[0].groupDescription)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #5
0
 def test_dump_with_missing_attribute(self):
     """
     L{NodeSchema.dump} ignores missing attributes if C{min_occurs} is zero.
     """
     schema = NodeSchema("foo")
     schema.add(LeafSchema("bar"), min_occurs=0)
     foo = NodeItem(schema)
     self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
Example #6
0
 def test_dump_with_missing_attribute(self):
     """
     L{NodeSchema.dump} ignores missing attributes if C{min_occurs} is zero.
     """
     schema = NodeSchema("foo")
     schema.add(LeafSchema("bar"), min_occurs=0)
     foo = NodeItem(schema)
     self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
Example #7
0
 def test_dump(self):
     """
     L{NodeSchema.dump} creates an L{etree.Element} out of a L{NodeItem}.
     """
     schema = NodeSchema("foo", [LeafSchema("bar")])
     foo = NodeItem(schema)
     foo.bar = "spam"
     self.assertEqual("<foo><bar>spam</bar></foo>",
                      etree.tostring(schema.dump(foo)))
Example #8
0
 def test_dump(self):
     """
     L{NodeSchema.dump} creates an L{etree.Element} out of a L{NodeItem}.
     """
     schema = NodeSchema("foo", [LeafSchema("bar")])
     foo = NodeItem(schema)
     foo.bar = "spam"
     self.assertEqual("<foo><bar>spam</bar></foo>",
                      etree.tostring(schema.dump(foo)))
Example #9
0
 def test_modify_describe_security_groups_response(self):
     """Modify a DescribeSecurityGroupsResponse payload."""
     schema = self.schemas["DescribeSecurityGroupsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = (b"<DescribeSecurityGroupsResponse xmlns=\"%s\">"
            b"<requestId>3ef0aa1d-57dd-4272</requestId>"
            b"<securityGroupInfo>"
            b"<item>"
            b"<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>"
            b"<groupName>WebServers</groupName>"
            b"<groupDescription>Web</groupDescription>"
            b"<ipPermissions>"
            b"<item>"
            b"<ipProtocol>tcp</ipProtocol>"
            b"<fromPort>80</fromPort>"
            b"<toPort>80</toPort>"
            b"<groups/>"
            b"<ipRanges>"
            b"<item>"
            b"<cidrIp>0.0.0.0/0</cidrIp>"
            b"</item>"
            b"</ipRanges>"
            b"</item>"
            b"</ipPermissions>"
            b"</item>"
            b"</securityGroupInfo>"
            b"</DescribeSecurityGroupsResponse>" % xmlns.encode())
     root = etree.fromstring(xml)
     response = schema.create(root)
     response.securityGroupInfo[0].ownerId = "abc123"
     response.securityGroupInfo[0].groupName = "Everybody"
     response.securityGroupInfo[0].groupDescription = "All People"
     xml = (b"<DescribeSecurityGroupsResponse xmlns=\"%s\">"
            b"<requestId>3ef0aa1d-57dd-4272</requestId>"
            b"<securityGroupInfo>"
            b"<item>"
            b"<ownerId>abc123</ownerId>"
            b"<groupName>Everybody</groupName>"
            b"<groupDescription>All People</groupDescription>"
            b"<ipPermissions>"
            b"<item>"
            b"<ipProtocol>tcp</ipProtocol>"
            b"<fromPort>80</fromPort>"
            b"<toPort>80</toPort>"
            b"<groups/>"
            b"<ipRanges>"
            b"<item>"
            b"<cidrIp>0.0.0.0/0</cidrIp>"
            b"</item>"
            b"</ipRanges>"
            b"</item>"
            b"</ipPermissions>"
            b"</item>"
            b"</securityGroupInfo>"
            b"</DescribeSecurityGroupsResponse>" % xmlns.encode())
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #10
0
 def test_dump_with_multiple_children(self):
     """
     L{NodeSchema.dump} supports multiple children.
     """
     schema = NodeSchema("foo", [LeafSchema("bar"), LeafSchema("egg")])
     foo = NodeItem(schema)
     foo.bar = "spam1"
     foo.egg = "spam2"
     self.assertEqual("<foo><bar>spam1</bar><egg>spam2</egg></foo>",
                      etree.tostring(schema.dump(foo)))
Example #11
0
 def test_dump_with_multiple_children(self):
     """
     L{NodeSchema.dump} supports multiple children.
     """
     schema = NodeSchema("foo", [LeafSchema("bar"), LeafSchema("egg")])
     foo = NodeItem(schema)
     foo.bar = "spam1"
     foo.egg = "spam2"
     self.assertEqual("<foo><bar>spam1</bar><egg>spam2</egg></foo>",
                      etree.tostring(schema.dump(foo)))
Example #12
0
 def test_dump(self):
     """
     L{SequenceSchema.dump} creates a L{etree.Element} out of
     a L{SequenceItem}.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     foo = SequenceItem(schema)
     foo.append().bar = "egg"
     self.assertEqual("<foo><item><bar>egg</bar></item></foo>",
                      etree.tostring(schema.dump(foo)))
Example #13
0
 def test_dump(self):
     """
     L{SequenceSchema.dump} creates a L{etree.Element} out of
     a L{SequenceItem}.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     foo = SequenceItem(schema)
     foo.append().bar = "egg"
     self.assertEqual("<foo><item><bar>egg</bar></item></foo>",
                      etree.tostring(schema.dump(foo)))
Example #14
0
 def test_set_with_non_required_tag(self):
     """
     It is possible to set a non-required tag value to C{None}, in that
     case the element will be removed if present.
     """
     schema = NodeSchema("foo")
     schema.add(LeafSchema("bar"), min_occurs=0)
     root = etree.fromstring("<foo><bar>spam</bar></foo>")
     foo = schema.create(root)
     foo.bar = None
     self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
Example #15
0
 def test_set_with_optional_node_tag(self):
     """
     It is possible to set an optional node tag to C{None}, in that
     case it will be removed from the tree.
     """
     schema = NodeSchema("foo")
     schema.add(NodeSchema("bar", [LeafSchema("egg")]), min_occurs=0)
     root = etree.fromstring("<foo><bar><egg>spam</egg></bar></foo>")
     foo = schema.create(root)
     foo.bar = None
     self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
Example #16
0
 def test_set_with_non_required_tag(self):
     """
     It is possible to set a non-required tag value to C{None}, in that
     case the element will be removed if present.
     """
     schema = NodeSchema("foo")
     schema.add(LeafSchema("bar"), min_occurs=0)
     root = etree.fromstring("<foo><bar>spam</bar></foo>")
     foo = schema.create(root)
     foo.bar = None
     self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
Example #17
0
 def test_set_with_optional_node_tag(self):
     """
     It is possible to set an optional node tag to C{None}, in that
     case it will be removed from the tree.
     """
     schema = NodeSchema("foo")
     schema.add(NodeSchema("bar", [LeafSchema("egg")]), min_occurs=0)
     root = etree.fromstring("<foo><bar><egg>spam</egg></bar></foo>")
     foo = schema.create(root)
     foo.bar = None
     self.assertEqual("<foo/>", etree.tostring(schema.dump(foo)))
Example #18
0
 def test_dump_with_many_items(self):
     """
     L{SequenceSchema.dump} supports many child items in the sequence.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     foo = SequenceItem(schema)
     foo.append().bar = "spam0"
     foo.append().bar = "spam1"
     self.assertEqual(
         "<foo>"
         "<item><bar>spam0</bar></item>"
         "<item><bar>spam1</bar></item>"
         "</foo>", etree.tostring(schema.dump(foo)))
Example #19
0
 def test_parse_delete_key_pair_response(self):
     """Parse a DeleteKeyPairResponse payload."""
     schema = self.schemas["DeleteKeyPairResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = ("<DeleteKeyPairResponse xmlns=\"%s\">"
            "<requestId>acc41b73-4c47-4f80</requestId>"
            "<return>true</return>"
            "</DeleteKeyPairResponse>" % xmlns)
     root = etree.fromstring(xml)
     response = schema.create(root)
     self.assertEqual("acc41b73-4c47-4f80", response.requestId)
     self.assertEqual("true", response.return_)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #20
0
 def test_get_with_non_required_nested(self):
     """
     It is possible to access a non-required nested node that has no
     associated element in the XML yet, in that case a new element is
     created for it.
     """
     schema = NodeSchema("foo")
     schema.add(NodeSchema("bar", [LeafSchema("egg")]), min_occurs=0)
     root = etree.fromstring("<foo/>")
     foo = schema.create(root)
     foo.bar.egg = "spam"
     self.assertEqual("<foo><bar><egg>spam</egg></bar></foo>",
                      etree.tostring(schema.dump(foo)))
Example #21
0
 def test_get_with_non_required_nested(self):
     """
     It is possible to access a non-required nested node that has no
     associated element in the XML yet, in that case a new element is
     created for it.
     """
     schema = NodeSchema("foo")
     schema.add(NodeSchema("bar", [LeafSchema("egg")]), min_occurs=0)
     root = etree.fromstring("<foo/>")
     foo = schema.create(root)
     foo.bar.egg = "spam"
     self.assertEqual("<foo><bar><egg>spam</egg></bar></foo>",
                      etree.tostring(schema.dump(foo)))
Example #22
0
 def test_parse_delete_key_pair_response(self):
     """Parse a DeleteKeyPairResponse payload."""
     schema = self.schemas["DeleteKeyPairResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     xml = ("<DeleteKeyPairResponse xmlns=\"%s\">"
            "<requestId>acc41b73-4c47-4f80</requestId>"
            "<return>true</return>"
            "</DeleteKeyPairResponse>" % xmlns)
     root = etree.fromstring(xml)
     response = schema.create(root)
     self.assertEqual("acc41b73-4c47-4f80", response.requestId)
     self.assertEqual("true", response.return_)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #23
0
 def test_dump_with_many_items(self):
     """
     L{SequenceSchema.dump} supports many child items in the sequence.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     foo = SequenceItem(schema)
     foo.append().bar = "spam0"
     foo.append().bar = "spam1"
     self.assertEqual("<foo>"
                      "<item><bar>spam0</bar></item>"
                      "<item><bar>spam1</bar></item>"
                      "</foo>",
                      etree.tostring(schema.dump(foo)))
Example #24
0
 def test_set_with_sequence_tag(self):
     """
     It is possible to set a sequence tag to C{None}, in that case
     all its children will be removed
     """
     schema = NodeSchema("foo")
     schema.add(SequenceSchema("bar",
                               NodeSchema("item", [LeafSchema("egg")])))
     root = etree.fromstring("<foo>"
                             "<bar><item><egg>spam</egg></item></bar><"
                             "/foo>")
     foo = schema.create(root)
     foo.bar = None
     self.assertEqual("<foo><bar/></foo>", etree.tostring(schema.dump(foo)))
Example #25
0
 def test_remove(self):
     """
     L{SequenceItem.remove} removes the given item from the sequence.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     root = etree.fromstring("<foo>"
                             "<item><bar>egg0</bar></item>"
                             "<item><bar>egg1</bar></item>"
                             "</foo>")
     foo = schema.create(root)
     foo.remove(foo[0])
     self.assertEqual("egg1", foo[0].bar)
     self.assertEqual("<foo><item><bar>egg1</bar></item></foo>",
                      etree.tostring(schema.dump(foo)))
Example #26
0
 def test_set_with_sequence_tag(self):
     """
     It is possible to set a sequence tag to C{None}, in that case
     all its children will be removed
     """
     schema = NodeSchema("foo")
     schema.add(
         SequenceSchema("bar", NodeSchema("item", [LeafSchema("egg")])))
     root = etree.fromstring("<foo>"
                             "<bar><item><egg>spam</egg></item></bar><"
                             "/foo>")
     foo = schema.create(root)
     foo.bar = None
     self.assertEqual("<foo><bar/></foo>", etree.tostring(schema.dump(foo)))
Example #27
0
 def test_remove(self):
     """
     L{SequenceItem.remove} removes the given item from the sequence.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     root = etree.fromstring("<foo>"
                             "<item><bar>egg0</bar></item>"
                             "<item><bar>egg1</bar></item>"
                             "</foo>")
     foo = schema.create(root)
     foo.remove(foo[0])
     self.assertEqual("egg1", foo[0].bar)
     self.assertEqual("<foo><item><bar>egg1</bar></item></foo>",
                      etree.tostring(schema.dump(foo)))
Example #28
0
 def test_delitem(self):
     """
     L{SequenceItem.__delitem__} removes from the sequence the item with the
     given index.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     root = etree.fromstring("<foo>"
                             "<item><bar>egg0</bar></item>"
                             "<item><bar>egg1</bar></item>"
                             "</foo>")
     foo = schema.create(root)
     del foo[0]
     self.assertEqual("egg1", foo[0].bar)
     self.assertEqual("<foo><item><bar>egg1</bar></item></foo>",
                      etree.tostring(schema.dump(foo)))
Example #29
0
 def test_append(self):
     """
     L{SequenceItem.append} adds a new item to the sequence, appending it
     at the end.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     root = etree.fromstring("<foo><item><bar>egg0</bar></item></foo>")
     foo = schema.create(root)
     foo.append().bar = "egg1"
     self.assertEqual("egg1", foo[1].bar)
     self.assertEqual(
         "<foo>"
         "<item><bar>egg0</bar></item>"
         "<item><bar>egg1</bar></item>"
         "</foo>", etree.tostring(schema.dump(foo)))
Example #30
0
 def test_append(self):
     """
     L{SequenceItem.append} adds a new item to the sequence, appending it
     at the end.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     root = etree.fromstring("<foo><item><bar>egg0</bar></item></foo>")
     foo = schema.create(root)
     foo.append().bar = "egg1"
     self.assertEqual("egg1", foo[1].bar)
     self.assertEqual("<foo>"
                      "<item><bar>egg0</bar></item>"
                      "<item><bar>egg1</bar></item>"
                      "</foo>",
                      etree.tostring(schema.dump(foo)))
Example #31
0
 def test_delitem(self):
     """
     L{SequenceItem.__delitem__} removes from the sequence the item with the
     given index.
     """
     schema = SequenceSchema("foo", NodeSchema("item", [LeafSchema("bar")]))
     root = etree.fromstring("<foo>"
                             "<item><bar>egg0</bar></item>"
                             "<item><bar>egg1</bar></item>"
                             "</foo>")
     foo = schema.create(root)
     del foo[0]
     self.assertEqual("egg1", foo[0].bar)
     self.assertEqual("<foo><item><bar>egg1</bar></item></foo>",
                      etree.tostring(schema.dump(foo)))
Example #32
0
    def test_parse_create_key_pair_response(self):
        """Parse a CreateKeyPairResponse payload."""
        schema = self.schemas["CreateKeyPairResponse"]
        xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
        xml = ("<CreateKeyPairResponse xmlns=\"%s\">"
               "<requestId>65d85081-abbc</requestId>"
               "<keyName>foo</keyName>"
               "<keyFingerprint>9a:81:96:46</keyFingerprint>"
               "<keyMaterial>MIIEowIBAAKCAQEAi</keyMaterial>"
               "</CreateKeyPairResponse>" % xmlns)

        response = schema.create(etree.fromstring(xml))
        self.assertEqual("65d85081-abbc", response.requestId)
        self.assertEqual("foo", response.keyName)
        self.assertEqual("9a:81:96:46", response.keyFingerprint)
        self.assertEqual("MIIEowIBAAKCAQEAi", response.keyMaterial)
        self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #33
0
    def test_parse_create_key_pair_response(self):
        """Parse a CreateKeyPairResponse payload."""
        schema = self.schemas["CreateKeyPairResponse"]
        xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
        xml = ("<CreateKeyPairResponse xmlns=\"%s\">"
               "<requestId>65d85081-abbc</requestId>"
               "<keyName>foo</keyName>"
               "<keyFingerprint>9a:81:96:46</keyFingerprint>"
               "<keyMaterial>MIIEowIBAAKCAQEAi</keyMaterial>"
               "</CreateKeyPairResponse>" % xmlns)

        response = schema.create(etree.fromstring(xml))
        self.assertEqual("65d85081-abbc", response.requestId)
        self.assertEqual("foo", response.keyName)
        self.assertEqual("9a:81:96:46", response.keyFingerprint)
        self.assertEqual("MIIEowIBAAKCAQEAi", response.keyMaterial)
        self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #34
0
 def test_create_describe_addresses_response(self):
     """Create a DescribeAddressesResponse payload.
     """
     schema = self.schemas["DescribeAddressesResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "abc"
     address = response.addressesSet.append()
     address.publicIp = "192.168.0.1"
     xml = ("<DescribeAddressesResponse xmlns=\"%s\">"
            "<requestId>abc</requestId>"
            "<addressesSet>"
            "<item>"
            "<publicIp>192.168.0.1</publicIp>"
            "</item>"
            "</addressesSet>"
            "</DescribeAddressesResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #35
0
 def test_create_describe_addresses_response(self):
     """Create a DescribeAddressesResponse payload.
     """
     schema = self.schemas["DescribeAddressesResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "abc"
     address = response.addressesSet.append()
     address.publicIp = "192.168.0.1"
     xml = ("<DescribeAddressesResponse xmlns=\"%s\">"
            "<requestId>abc</requestId>"
            "<addressesSet>"
            "<item>"
            "<publicIp>192.168.0.1</publicIp>"
            "</item>"
            "</addressesSet>"
            "</DescribeAddressesResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #36
0
 def test_create_describe_key_pairs_response(self):
     """Create a DescribeKeyPairsResponse payload."""
     schema = self.schemas["DescribeKeyPairsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "abc"
     key = response.keySet.append()
     key.keyName = "some-key"
     key.keyFingerprint = "11:22:33:44"
     xml = ("<DescribeKeyPairsResponse xmlns=\"%s\">"
            "<requestId>abc</requestId>"
            "<keySet>"
            "<item>"
            "<keyName>some-key</keyName>"
            "<keyFingerprint>11:22:33:44</keyFingerprint>"
            "</item>"
            "</keySet>"
            "</DescribeKeyPairsResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #37
0
 def test_create_describe_key_pairs_response(self):
     """Create a DescribeKeyPairsResponse payload."""
     schema = self.schemas["DescribeKeyPairsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "abc"
     key = response.keySet.append()
     key.keyName = "some-key"
     key.keyFingerprint = "11:22:33:44"
     xml = ("<DescribeKeyPairsResponse xmlns=\"%s\">"
            "<requestId>abc</requestId>"
            "<keySet>"
            "<item>"
            "<keyName>some-key</keyName>"
            "<keyFingerprint>11:22:33:44</keyFingerprint>"
            "</item>"
            "</keySet>"
            "</DescribeKeyPairsResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #38
0
 def test_create_describe_security_groups_response(self):
     """Create a DescribeSecurityGroupsResponse payload."""
     schema = self.schemas["DescribeSecurityGroupsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "requestId123"
     group = response.securityGroupInfo.append()
     group.ownerId = "deadbeef31337"
     group.groupName = "hexadecimalonly"
     group.groupDescription = "All people that love hex"
     xml = ("<DescribeSecurityGroupsResponse xmlns=\"%s\">"
            "<requestId>requestId123</requestId>"
            "<securityGroupInfo>"
            "<item>"
            "<ownerId>deadbeef31337</ownerId>"
            "<groupName>hexadecimalonly</groupName>"
            "<groupDescription>All people that love hex</groupDescription>"
            "</item>"
            "</securityGroupInfo>"
            "</DescribeSecurityGroupsResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #39
0
 def test_create_describe_security_groups_response(self):
     """Create a DescribeSecurityGroupsResponse payload."""
     schema = self.schemas["DescribeSecurityGroupsResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "requestId123"
     group = response.securityGroupInfo.append()
     group.ownerId = "deadbeef31337"
     group.groupName = "hexadecimalonly"
     group.groupDescription = "All people that love hex"
     xml = ("<DescribeSecurityGroupsResponse xmlns=\"%s\">"
            "<requestId>requestId123</requestId>"
            "<securityGroupInfo>"
            "<item>"
            "<ownerId>deadbeef31337</ownerId>"
            "<groupName>hexadecimalonly</groupName>"
            "<groupDescription>All people that love hex</groupDescription>"
            "</item>"
            "</securityGroupInfo>"
            "</DescribeSecurityGroupsResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #40
0
 def test_create_describe_instances_response(self):
     """Create a DescribeInstancesResponse payload.
     """
     schema = self.schemas["DescribeInstancesResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "abc"
     reservation = response.reservationSet.append()
     instance = reservation.instancesSet.append()
     instance.instanceId = "i-01234567"
     xml = ("<DescribeInstancesResponse xmlns=\"%s\">"
            "<requestId>abc</requestId>"
            "<reservationSet>"
            "<item>"
            "<instancesSet>"
            "<item>"
            "<instanceId>i-01234567</instanceId>"
            "</item>"
            "</instancesSet>"
            "</item>"
            "</reservationSet>"
            "</DescribeInstancesResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))
Example #41
0
 def test_create_describe_instances_response(self):
     """Create a DescribeInstancesResponse payload.
     """
     schema = self.schemas["DescribeInstancesResponse"]
     xmlns = "http://ec2.amazonaws.com/doc/2008-12-01/"
     response = schema.create(namespace=xmlns)
     response.requestId = "abc"
     reservation = response.reservationSet.append()
     instance = reservation.instancesSet.append()
     instance.instanceId = "i-01234567"
     xml = ("<DescribeInstancesResponse xmlns=\"%s\">"
            "<requestId>abc</requestId>"
            "<reservationSet>"
            "<item>"
            "<instancesSet>"
            "<item>"
            "<instanceId>i-01234567</instanceId>"
            "</item>"
            "</instancesSet>"
            "</item>"
            "</reservationSet>"
            "</DescribeInstancesResponse>" % xmlns)
     self.assertEqual(xml, etree.tostring(schema.dump(response)))