test_scaffolding.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright 2023 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import os
  12. from cookiecutter.main import cookiecutter
  13. from src.taipy._cli._scaffold_cli import _ScaffoldCLI
  14. def test_create_call_to_cookiecutter():
  15. assert os.path.exists(_ScaffoldCLI._TEMPLATE_MAP["default"])
  16. assert os.listdir(_ScaffoldCLI._TEMPLATE_MAP["default"]) == [
  17. "cookiecutter.json",
  18. "{{cookiecutter.application_name}}",
  19. ]
  20. def test_static_and_templates(tmpdir):
  21. cookiecutter(
  22. template=_ScaffoldCLI._TEMPLATE_MAP["default"],
  23. output_dir=str(tmpdir),
  24. no_input=True,
  25. extra_context={
  26. "application_name": "foo_app",
  27. "application_main_file": "main.py",
  28. "application_title": "bar",
  29. },
  30. )
  31. assert os.listdir(tmpdir) == ["foo_app"]
  32. assert os.listdir(os.path.join(tmpdir, "foo_app")).sort() == ["requirements.txt", "main.py", "images"].sort()