From cf31c37a68df4d87d189ff4d08a73d18874a09b9 Mon Sep 17 00:00:00 2001 From: Anton Mokhovikov Date: Fri, 17 Jul 2020 15:57:46 -0700 Subject: [PATCH] changed from exception to warning --- src/rpdk/core/data_loaders.py | 2 +- src/rpdk/core/project.py | 2 +- tests/data/schema/{invalid => valid}/invalid_primary_id.json | 0 tests/test_project.py | 4 +++- 4 files changed, 5 insertions(+), 3 deletions(-) rename tests/data/schema/{invalid => valid}/invalid_primary_id.json (100%) diff --git a/src/rpdk/core/data_loaders.py b/src/rpdk/core/data_loaders.py index 9e97ee24..7a279ff4 100644 --- a/src/rpdk/core/data_loaders.py +++ b/src/rpdk/core/data_loaders.py @@ -118,7 +118,7 @@ def load_resource_spec(resource_spec_file): # noqa: C901 primary_id = resource_spec["primaryIdentifier"] if not in_readonly(primary_id) and not in_createonly(primary_id): - raise SpecValidationError( + LOG.warning( "Property 'primaryIdentifier' must be specified \ as either readOnly or createOnly" ) diff --git a/src/rpdk/core/project.py b/src/rpdk/core/project.py index 608729a7..9296fbd8 100644 --- a/src/rpdk/core/project.py +++ b/src/rpdk/core/project.py @@ -249,7 +249,7 @@ def safewrite(self, path, contents): else: f.write(contents) except FileExistsError: - LOG.warning("File already exists, not overwriting '%s'", path) + LOG.info("File already exists, not overwriting '%s'", path) def generate(self): # generate template for IAM role assumed by cloudformation diff --git a/tests/data/schema/invalid/invalid_primary_id.json b/tests/data/schema/valid/invalid_primary_id.json similarity index 100% rename from tests/data/schema/invalid/invalid_primary_id.json rename to tests/data/schema/valid/invalid_primary_id.json diff --git a/tests/test_project.py b/tests/test_project.py index 9cbff737..ccc6e662 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,6 +1,7 @@ # fixture and parameter have the same name # pylint: disable=redefined-outer-name,useless-super-delegation,protected-access import json +import logging import os import random import string @@ -174,6 +175,7 @@ def test_safewrite_doesnt_exist(project, tmpdir): def test_safewrite_exists(project, tmpdir, caplog): + caplog.set_level(logging.INFO) path = Path(tmpdir.join("test")).resolve() with path.open("w", encoding="utf-8") as f: @@ -183,7 +185,7 @@ def test_safewrite_exists(project, tmpdir, caplog): project.safewrite(path, CONTENTS_UTF8) last_record = caplog.records[-1] - assert last_record.levelname == "WARNING" + assert last_record.levelname == "INFO" assert str(path) in last_record.message