Skip to content

Commit

Permalink
inputs -> example imputs (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
ammokhov authored Sep 8, 2020
1 parent 9e0dca0 commit 059b858
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/rpdk/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
SCHEMA_UPLOAD_FILENAME = "schema.json"
OVERRIDES_FILENAME = "overrides.json"
INPUTS_FOLDER = "inputs"
EXAMPLE_INPUTS_FOLDER = "example_inputs"
ROLE_TEMPLATE_FILENAME = "resource-role.yaml"
TYPE_NAME_REGEX = "^[a-zA-Z0-9]{2,64}::[a-zA-Z0-9]{2,64}::[a-zA-Z0-9]{2,64}$"

Expand Down Expand Up @@ -147,6 +148,10 @@ def overrides_path(self):
def inputs_path(self):
return self.root / INPUTS_FOLDER

@property
def example_inputs_path(self):
return self.root / EXAMPLE_INPUTS_FOLDER

@staticmethod
def _raise_invalid_project(msg, e):
LOG.debug(msg, exc_info=e)
Expand Down Expand Up @@ -191,8 +196,8 @@ def _write(f):

def _write_example_inputs(self):

shutil.rmtree(self.inputs_path, ignore_errors=True)
self.inputs_path.mkdir(exist_ok=True)
shutil.rmtree(self.example_inputs_path, ignore_errors=True)
self.example_inputs_path.mkdir(exist_ok=True)

template = self.env.get_template("inputs.json")
properties = list(self.schema["properties"].keys())
Expand All @@ -203,7 +208,7 @@ def _write_example_inputs(self):
"inputs_1_invalid.json",
):
self.safewrite(
self.inputs_path / inputs_file,
self.example_inputs_path / inputs_file,
template.render(
properties=properties[:-1], last_property=properties[-1]
),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def test_init(project):
"inputs_1_update.json",
"inputs_1_invalid.json",
):
path_file = project.inputs_path / file_inputs
path_file = project.example_inputs_path / file_inputs
with path_file.open("r", encoding="utf-8") as f:
assert json.load(f)

Expand Down

0 comments on commit 059b858

Please sign in to comment.