Example #1
0
    def test_success(self):
        """
        The top one will have to spill over into the second network
        """

        expected = {
            "status": "SUCCESS",
            "reason": None,
            "data": {
                "CidrBlock1": "10.0.1.128/25",
                "CidrBlock2": "10.0.128.0/17",
                "CidrBlock3": "10.1.128.0/17",
            },
        }

        request = {
            "RequestType": "Create",
            "ResourceProperties": {
                "VpcId": "",
                "Sizes": ["25", "17", "17"],
            },
        }

        handler(request, {}, responder=self.__responder, client=MockEc2())

        self.assertEqual(self.response, expected)
Example #2
0
    def test_delete(self):
        expected = {
            "status": "SUCCESS",
            "reason": None,
            "data": {},
        }

        handler({"RequestType": "Delete"}, {}, responder=self.__responder)

        self.assertEqual(self.response, expected)
Example #3
0
    def test_missing_both(self):
        expected = {
            "status": "FAILED",
            "reason": "Missing parameter(s): VpcId, Sizes",
            "data": {},
        }

        request = {
            "RequestType": "Create",
            "ResourceProperties": {},
        }

        handler(request, {}, responder=self.__responder)

        self.assertEqual(self.response, expected)
Example #4
0
    def test_request_too_large(self):
        expected = {
            "status": "FAILED",
            "reason": "Not enough space for the requested CIDR blocks",
            "data": {},
        }

        request = {
            "RequestType": "Create",
            "ResourceProperties": {
                "VpcId": "",
                "Sizes": ["16"],
            },
        }

        handler(request, {}, responder=self.__responder, client=MockEc2())

        self.assertEqual(self.response, expected)
Example #5
0
    def test_bad_sizes(self):
        expected = {
            "status": "FAILED",
            "reason": "An invalid subnet size was specified: 23, camel, 25",
            "data": {},
        }

        request = {
            "RequestType": "Create",
            "ResourceProperties": {
                "VpcId": "",
                "Sizes": ["23", "camel", "25"],
            },
        }

        handler(request, {}, responder=self.__responder)

        self.assertEqual(self.response, expected)