def test_list_function_versions(self):
        with self.app.test_request_context():
            self._create_function(self.FUNCTION_NAME)
            lambda_api.publish_version(self.FUNCTION_NAME)
            lambda_api.publish_version(self.FUNCTION_NAME)

            result = json.loads(
                lambda_api.list_versions(self.FUNCTION_NAME).get_data())

            latest_version = dict()
            latest_version['CodeSize'] = self.CODE_SIZE
            latest_version['FunctionArn'] = str(
                lambda_api.func_arn(self.FUNCTION_NAME)) + ':$LATEST'
            latest_version['FunctionName'] = str(self.FUNCTION_NAME)
            latest_version['Handler'] = str(self.HANDLER)
            latest_version['Runtime'] = str(self.RUNTIME)
            latest_version['Timeout'] = self.TIMEOUT
            latest_version['Version'] = '$LATEST'
            latest_version['Environment'] = {}
            version1 = dict(latest_version)
            version1['FunctionArn'] = str(
                lambda_api.func_arn(self.FUNCTION_NAME)) + ':1'
            version1['Version'] = '1'
            version1['Environment'] = {}
            version2 = dict(latest_version)
            version2['FunctionArn'] = str(
                lambda_api.func_arn(self.FUNCTION_NAME)) + ':2'
            version2['Version'] = '2'
            version2['Environment'] = {}
            expected_result = {
                'Versions':
                sorted([latest_version, version1, version2],
                       key=lambda k: str(k.get('Version')))
            }
            self.assertDictEqual(expected_result, result)
Exemple #2
0
    def test_list_function_versions(self):
        with self.app.test_request_context():
            self._create_function(self.FUNCTION_NAME)
            lambda_api.publish_version(self.FUNCTION_NAME)
            lambda_api.publish_version(self.FUNCTION_NAME)

            result = json.loads(lambda_api.list_versions(self.FUNCTION_NAME).get_data())
            for version in result['Versions']:
                # we need to remove this, since this is random, so we cannot know its value
                version.pop('RevisionId', None)

            latest_version = dict()
            latest_version['CodeSize'] = self.CODE_SIZE
            latest_version['CodeSha256'] = self.CODE_SHA_256
            latest_version['FunctionArn'] = str(lambda_api.func_arn(self.FUNCTION_NAME)) + ':$LATEST'
            latest_version['FunctionName'] = str(self.FUNCTION_NAME)
            latest_version['Handler'] = str(self.HANDLER)
            latest_version['Runtime'] = str(self.RUNTIME)
            latest_version['Timeout'] = self.TIMEOUT
            latest_version['Description'] = ''
            latest_version['MemorySize'] = self.MEMORY_SIZE
            latest_version['Role'] = self.ROLE
            latest_version['LastModified'] = self.LAST_MODIFIED
            latest_version['TracingConfig'] = self.TRACING_CONFIG
            latest_version['Version'] = '$LATEST'
            version1 = dict(latest_version)
            version1['FunctionArn'] = str(lambda_api.func_arn(self.FUNCTION_NAME)) + ':1'
            version1['Version'] = '1'
            version2 = dict(latest_version)
            version2['FunctionArn'] = str(lambda_api.func_arn(self.FUNCTION_NAME)) + ':2'
            version2['Version'] = '2'
            expected_result = {'Versions': sorted([latest_version, version1, version2],
                                                  key=lambda k: str(k.get('Version')))}
            self.assertDictEqual(expected_result, result)
 def test_list_non_existant_function_versions_returns_error(self):
     with self.app.test_request_context():
         result = json.loads(
             lambda_api.list_versions(self.FUNCTION_NAME).get_data())
         self.assertEqual(self.RESOURCENOTFOUND_EXCEPTION, result['__type'])
         self.assertEqual(
             self.RESOURCENOTFOUND_MESSAGE %
             lambda_api.func_arn(self.FUNCTION_NAME), result['message'])
Exemple #4
0
    def test_list_function_versions(self):
        with self.app.test_request_context():
            self._create_function(self.FUNCTION_NAME)
            lambda_api.publish_version(self.FUNCTION_NAME)
            lambda_api.publish_version(self.FUNCTION_NAME)

            result = json.loads(
                lambda_api.list_versions(self.FUNCTION_NAME).get_data())
            for version in result["Versions"]:
                # we need to remove this, since this is random, so we cannot know its value
                version.pop("RevisionId", None)

            latest_version = dict()
            latest_version["CodeSize"] = self.CODE_SIZE
            latest_version["CodeSha256"] = self.CODE_SHA_256
            latest_version["FunctionArn"] = (
                str(lambda_api.func_arn(self.FUNCTION_NAME)) + ":$LATEST")
            latest_version["FunctionName"] = str(self.FUNCTION_NAME)
            latest_version["Handler"] = str(self.HANDLER)
            latest_version["Runtime"] = str(self.RUNTIME)
            latest_version["Timeout"] = self.TIMEOUT
            latest_version["Description"] = ""
            latest_version["MemorySize"] = self.MEMORY_SIZE
            latest_version["Role"] = self.ROLE
            latest_version["KMSKeyArn"] = None
            latest_version["VpcConfig"] = None
            latest_version["LastModified"] = isoformat_milliseconds(
                self.LAST_MODIFIED) + "+0000"
            latest_version["TracingConfig"] = self.TRACING_CONFIG
            latest_version["Version"] = "$LATEST"
            latest_version["State"] = "Active"
            latest_version["LastUpdateStatus"] = "Successful"
            latest_version["PackageType"] = None
            latest_version["ImageConfig"] = {}
            version1 = dict(latest_version)
            version1["FunctionArn"] = str(
                lambda_api.func_arn(self.FUNCTION_NAME)) + ":1"
            version1["Version"] = "1"
            expected_result = {
                "Versions":
                sorted([latest_version, version],
                       key=lambda k: str(k.get("Version")))
            }
            self.assertDictEqual(expected_result, result)