-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch from progress to message for init (#604)
- Snapcraft uses message, progress hides the docs url as it is "uni-line" - Use a similar message to what is done in Snapcraft - Improve the test for initializing flask-framework - Use the correct documentation slug --------- Co-authored-by: Tiago Nobrega <[email protected]>
- Loading branch information
1 parent
5ca1009
commit 2d9c6fc
Showing
3 changed files
with
107 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import pathlib | ||
import sys | ||
from pathlib import Path | ||
import textwrap | ||
from unittest.mock import DEFAULT, call | ||
|
||
import pytest | ||
|
@@ -117,12 +118,15 @@ def test_run_init_fallback_name(mocker): | |
assert rock_project.name == "my-rock-name" | ||
|
||
|
||
@pytest.mark.usefixtures("new_dir") | ||
def test_run_init_flask(mocker, tmp_path, monkeypatch): | ||
(tmp_path / "requirements.txt").write_text("flask") | ||
(tmp_path / "app.py").write_text("app = object()") | ||
mock_ended_ok = mocker.patch.object(emit, "ended_ok") | ||
mocker.patch.object(sys, "argv", ["rockcraft", "init", "--profile=flask-framework"]) | ||
def test_run_init_flask(mocker, emitter, monkeypatch, new_dir, tmp_path): | ||
(new_dir / "requirements.txt").write_text("Flask", encoding="utf-8") | ||
(new_dir / "app.py").write_text("app = object()", encoding="utf-8") | ||
|
||
mocker.patch.object( | ||
sys, | ||
"argv", | ||
["rockcraft", "init", "--profile=flask-framework", "--name", "test-name"], | ||
) | ||
|
||
cli.run() | ||
|
||
|
@@ -131,7 +135,80 @@ def test_run_init_flask(mocker, tmp_path, monkeypatch): | |
|
||
assert len(rock_project_yaml["summary"]) < 80 | ||
assert len(rock_project_yaml["description"].split()) < 100 | ||
assert mock_ended_ok.mock_calls == [call()] | ||
|
||
assert rockcraft_yaml_path.read_text() == textwrap.dedent( | ||
"""\ | ||
name: test-name | ||
# see https://documentation.ubuntu.com/rockcraft/en/stable/explanation/bases/ | ||
# for more information about bases and using 'bare' bases for chiselled rocks | ||
base: [email protected] # the base environment for this Flask application | ||
version: '0.1' # just for humans. Semantic versioning is recommended | ||
summary: A summary of your Flask application # 79 char long summary | ||
description: | | ||
This is test-name's description. You have a paragraph or two to tell the | ||
most important story about it. Keep it under 100 words though, | ||
we live in tweetspace and your description wants to look good in the | ||
container registries out there. | ||
platforms: # the platforms this rock should be built on and run on | ||
amd64: | ||
# to ensure the flask-framework extension works properly, your Flask application | ||
# should have an `app.py` file with an `app` object as the WSGI entrypoint. | ||
# a `requirements.txt` file with at least the flask package should also exist. | ||
# see https://documentation.ubuntu.com/rockcraft/en/stable/reference/extensions/flask-framework | ||
# for more information. | ||
extensions: | ||
- flask-framework | ||
# uncomment the sections you need and adjust according to your requirements. | ||
# parts: # you need to uncomment this line to add or update any part. | ||
# flask-framework/install-app: | ||
# prime: | ||
# # by default, only the files in app/, templates/, static/, migrate, | ||
# # migrate.sh and app.py are copied into the image. You can modify the list | ||
# # below to override the default list and include or exclude specific | ||
# # files/directories in your project. | ||
# # note: prefix each entry with "flask/app/" followed by the local path. | ||
# - flask/app/.env | ||
# - flask/app/app.py | ||
# - flask/app/webapp | ||
# - flask/app/templates | ||
# - flask/app/static | ||
# # you may need packages to build a python package. Add them here if necessary. | ||
# build-packages: | ||
# # for example, if you need pkg-config and libxmlsec1-dev to build one | ||
# # of your packages: | ||
# - pkg-config | ||
# - libxmlsec1-dev | ||
# you can add package slices or Debian packages to the image. | ||
# package slices are subsets of Debian packages, which result | ||
# in smaller and more secure images. | ||
# see https://documentation.ubuntu.com/rockcraft/en/latest/explanation/chisel/ | ||
# add this part if you want to add packages slices to your image. | ||
# you can find a list of packages slices at https://github.com/canonical/chisel-releases | ||
# flask-framework/runtime-slices: | ||
# plugin: nil | ||
# stage-packages: | ||
# # list the required package slices for your flask application below. | ||
# # for example, for the slice libs of libpq5: | ||
# - libpq5_libs | ||
# if you want to add a Debian package to your image, add the next part | ||
# flask-framework/runtime-debs: | ||
# plugin: nil | ||
# stage-packages: | ||
# # list required Debian packages for your flask application below. | ||
# - libpq5 | ||
""" | ||
) | ||
emitter.assert_message( | ||
textwrap.dedent( | ||
"""\ | ||
Created 'rockcraft.yaml'. | ||
Go to https://documentation.ubuntu.com/rockcraft/en/stable/reference/extensions/flask-framework to read more about the 'flask-framework' profile.""" | ||
) | ||
) | ||
monkeypatch.setenv("ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS", "0") | ||
project.Project.unmarshal(extensions.apply_extensions(tmp_path, rock_project_yaml)) |