Conversation
freakboy3742
left a comment
There was a problem hiding this comment.
This is definitely on the right track; two comments inline regarding the implementation.
There's also a need for tests. Briefcase has 100% branch coverage, and any new feature requires tests of that new feature. The Briefcase contribution guide (in the docs) has pointers on how to set up a local testing environment.
If you need any pointers on these points, let us know and I'll do what I can to help.
src/briefcase/commands/convert.py
Outdated
| ): | ||
| return { | ||
| "gui_framework": "None", | ||
| "pyproject_table_briefcase_app_extra_content": "\nconsole_app = true\n", |
There was a problem hiding this comment.
If this is a feature we're going to rely on, we should probably add console_app as a feature in the Briefcase template itself, rather than slipping it into "extra" content.
There was a problem hiding this comment.
alright, I will make a commit there first. should I open an issue first?
Thanks for the guidance.
There was a problem hiding this comment.
There's no need for a separate issue; you can use Refs beeware/briefcase#1234 syntax to reference an issue or PR in a separate project.
Hi, I get this error in coverage test, but I can not completely understand what I am doing wrong. I would be grateful if you can point me in right direction. My analysis:- Possible solution:-
Thanks, |
The underlying issue is that as a result of the changes you've made, the test in question is now asking for user input. This input is controllable, in multiple ways - see the tests for However, in this case, the test is misleadingly named, and it should be verifying that overrides are being used - so, your option 2. |
|
I believe I have aptly addressed the requested changes, let me know if I am wrong or more changes are required. |
freakboy3742
left a comment
There was a problem hiding this comment.
This is getting pretty close; a couple of minor issues flagged inline, several of which are tied to the exact form of the template.
The only additional detail that needs to be modified is the handling of console mode for new apps. At present, the Console bootstrap (briefcase.bootstraps.console) includes console_app = true as a hard-coded string in the pyproject_table_briefcase_app_extra_content configuration. For consistency, this should probably be handled as a boolean flag on the bootstrap itself (by subclassing extra_context()) that will be passed down to the bootstrap template.
| assert out["gui_framework"] == "None" | ||
| assert overrides["gui_framework"] == "Toga" |
There was a problem hiding this comment.
This changes the test quite a bit - it goes from checking the entire contents of the dictionary, to checking one specific field in the dictionary. If the method adds additional fields, the test won't raise this as a failure.
src/briefcase/commands/convert.py
Outdated
| console_app = "true" | ||
| else: | ||
| console_app = "false" |
There was a problem hiding this comment.
Matching the changes I made to the template - should this be a string, or a boolean? I suspect it should be a boolean. input_console_app is already outputting a boolean.
There was a problem hiding this comment.
I think, it should be string since making console_app a boolean renders console_app in pyproject.toml to True instead of true, or is it case insensitive?
There was a problem hiding this comment.
TOML parsing is case sensitive; I'd argue this means the template should use {{ "True" if console_app else "False" }}. The template context should be "pure" data; the template then renders that context as necessary to produce valid TOML.
| def test_overrides_are_used_for_GUI(convert_command): | ||
| overrides = {"console_app": "GUI"} | ||
| out = convert_command.build_gui_context({}, overrides) | ||
| assert out["console_app"] == "false" |
There was a problem hiding this comment.
There should also be a test of the two "normal" cases, where user input is provided.
from suggested changes Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
from suggested changes Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
…de/briefcase into console_app_on_convert
freakboy3742
left a comment
There was a problem hiding this comment.
Getting close; most of the issues now stem from the exact value being put into the template context
src/briefcase/commands/convert.py
Outdated
| console_app = "true" | ||
| else: | ||
| console_app = "false" |
There was a problem hiding this comment.
TOML parsing is case sensitive; I'd argue this means the template should use {{ "True" if console_app else "False" }}. The template context should be "pure" data; the template then renders that context as necessary to produce valid TOML.
| default=None, | ||
| options=["GUI", "Console"], | ||
| override_value=None, | ||
| ) |
There was a problem hiding this comment.
This validates that the method is called; but doesn't validate the return value of the method being invoked.
There was a problem hiding this comment.
Right, test_input_is_used_GUI and test_input_is_used_Console are supposed to validate returned value(just below this function), I saw that other input functions had similar test to check if the function is being called properly, so I added one for this one too.
There was a problem hiding this comment.
Sure - my point is that this test is incomplete. If you're invoking a function, you should be ensuring that the return value is what you expect.
However, the test itself is actually redundant. We don't actually care if select_option is invoked - that's testing a specific implementation detail. What we care about is the "black box" behavior - that if the user types 1/0 after invoking the method, a False/True value is returned; for bonus points, we can also check the default, and error handling options. Those outcomes are established by the subsequent tests (which can be parameterised to account for the other input options).
| assert out == {"gui_framework": "None"} | ||
| assert overrides == {"gui_framework": "Toga"} | ||
| assert out == {"gui_framework": "None", "console_app": "true"} | ||
| assert overrides["gui_framework"] == "Toga" |
There was a problem hiding this comment.
I mentioned this in a previous review, but this is changing the nature of the assertion from a full dictionary to a single key.
freakboy3742
left a comment
There was a problem hiding this comment.
Thanks for those updates - other than a couple of minor issues that I've updated manually, this looks great! Thanks for the contribution!
| default=None, | ||
| options=["GUI", "Console"], | ||
| override_value=None, | ||
| ) |
There was a problem hiding this comment.
Sure - my point is that this test is incomplete. If you're invoking a function, you should be ensuring that the return value is what you expect.
However, the test itself is actually redundant. We don't actually care if select_option is invoked - that's testing a specific implementation detail. What we care about is the "black box" behavior - that if the user types 1/0 after invoking the method, a False/True value is returned; for bonus points, we can also check the default, and error handling options. Those outcomes are established by the subsequent tests (which can be parameterised to account for the other input options).
src/briefcase/commands/convert.py
Outdated
| project_overrides: dict[str, str], | ||
| ) -> dict[str, str]: | ||
| # We must set the GUI-framework to None here since the convert-command uses the new-command | ||
| # We must set the GUI-framework to None here since the convert-command uses the new-commandcd |
There was a problem hiding this comment.
Looks like a window focus typo.
freakboy3742
left a comment
There was a problem hiding this comment.
Wait - I just realised I missed something - the handling of console_app in the console app bootstrap. One more small update to come.

Describe your changes in detail
I have added prompt that asks whether the given app is console_app and adds corresponding configuration to pyproject.toml.
also provides corresponding override by the name of console_app
What problem does this change solve?
It addresses the need to manually change pyproject.toml when converting console apps.
If this PR relates to an issue, include Refs #XXX or Fixes #XXX
Fixes #1900
PR Checklist: