Skip to content

Commit 3e5a461

Browse files
authored
Merge pull request #95 from minos-framework/issue-93-use-same-template-version-in-links
#93 - Do not let registry get overridden.
2 parents e94a83a + 763a251 commit 3e5a461

File tree

5 files changed

+59
-17
lines changed

5 files changed

+59
-17
lines changed

.github/workflows/python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: make coverage
2525

2626
- name: Publish coverage
27-
uses: codecov/codecov-action@v1.3.1
27+
uses: codecov/codecov-action@v2
2828
with:
2929
token: ${{ secrets.CODECOV_TOKEN }}
3030
files: ./coverage.xml

minos/cli/templating/processors.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def answers(self) -> dict[str, Any]:
135135
:return: A mapping from question name to the answer value.
136136
"""
137137
answers = self.context
138-
answers |= self._previous_answers
138+
answers |= self._previous_answers_without_template_registry
139139

140140
answers = self.form.ask(context=answers, env=self.env)
141141
self._store_new_answers(answers)
@@ -154,6 +154,14 @@ def _previous_answers(self) -> dict[str, str]:
154154

155155
return answers
156156

157+
@cached_property
158+
def _previous_answers_without_template_registry(self):
159+
previous_answers_without_registry = self._previous_answers.copy()
160+
previous_answers_without_registry.pop("template_registry", None)
161+
previous_answers_without_registry.pop("template_version", None)
162+
163+
return previous_answers_without_registry
164+
157165
def _store_new_answers(self, answers) -> None:
158166
with self._answers_file_path.open("w") as file:
159167
yaml.dump(answers, file)

poetry.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ coverage = "^5.5"
4545
flake8 = "^3.9.2"
4646
Sphinx = "^4.0.1"
4747
pre-commit = "^2.12.1"
48-
sphinx-autodoc-typehints = "^1.12.0"
48+
sphinx-autodoc-typehints = "^1.17.0"
4949
sphinxcontrib-apidoc = "^0.3.0"
50-
sphinx-rtd-theme = "^0.5.2"
50+
sphinx-rtd-theme = "^1.0.0"
5151
m2r2 = "^0.3.2"
5252

5353
[build-system]

tests/test_cli/test_templating/test_processors.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,40 @@ def test_answers_with_previous_answers(self):
118118
answers = yaml.safe_load(file)
119119
self.assertEqual(expected_answers, answers)
120120

121+
def test_answers_do_not_override_template_registry_and_version(self):
122+
expected_answers = {
123+
"foo": "foo_answer",
124+
"template_registry": f"{TEMPLATE_URL}/{TEMPLATE_VERSION}",
125+
"template_version": TEMPLATE_VERSION,
126+
}
127+
with TemporaryDirectory() as tmp_dir_name:
128+
project_destination = Path(tmp_dir_name)
129+
(project_destination / ".minos-project.yaml").touch()
130+
minos_answers_file = project_destination / ".minos-answers.yml"
131+
minos_answers_file.touch()
132+
133+
with minos_answers_file.open("w") as file:
134+
answers_with_wrong_version = {
135+
"foo": "foo_answer",
136+
"template_registry": f"{TEMPLATE_URL}/wrong_version",
137+
"template_version": "wrong_version",
138+
}
139+
yaml.dump(
140+
answers_with_wrong_version, file,
141+
)
142+
143+
microservice_destination = project_destination / "microservices" / "foo"
144+
microservice_destination.mkdir(parents=True)
145+
146+
processor = TemplateProcessor.from_fetcher(self.fetcher, microservice_destination,)
147+
148+
with patch("minos.cli.Form.ask", return_value=expected_answers) as mock:
149+
self.assertEqual(expected_answers, processor.answers)
150+
151+
self.assertEqual(
152+
[call(context=processor.context | expected_answers, env=processor.env)], mock.call_args_list,
153+
)
154+
121155
def test_answers_without_previous_answers(self):
122156
with TemporaryDirectory() as tmp_dir_name:
123157
destination = Path(tmp_dir_name)

0 commit comments

Comments
 (0)