Skip to content

Moved generate_json_map to new module#226

Open
adedamola-sode wants to merge 7 commits into
mainfrom
separate-json-map
Open

Moved generate_json_map to new module#226
adedamola-sode wants to merge 7 commits into
mainfrom
separate-json-map

Conversation

@adedamola-sode
Copy link
Copy Markdown
Collaborator

Moved generate_json_map to new module called generate_jsonmap.

  1. generate-jsonmap can now be called on the command line
  2. It can also be called with an argument when using techui-builder "--generate-jsonmap or -j "

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 95.94595% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.27%. Comparing base (135097f) to head (b1d6841).

Files with missing lines Patch % Lines
src/techui_builder/generate_jsonmap.py 96.63% 7 Missing ⚠️
src/techui_builder/__main__.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
- Coverage   95.28%   95.27%   -0.01%     
==========================================
  Files          10       11       +1     
  Lines         890      932      +42     
==========================================
+ Hits          848      888      +40     
- Misses         42       44       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +145 to +153
# Set top level display name from root element
current_node.display_name = self._parse_display_name(
root.name.text, screen_path
)
current_node.display_name = self._get_component_label(
name_elem,
current_component_name,
current_node.display_name,
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be replaced with the _get_display_name() function?

Comment on lines +59 to +60
if self.techui == Path("techui.yaml"):
self.techui = self._write_directory.joinpath("techui.yaml")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will just compare to the default value of the field instead of hard-coding it, and will also only overwrite it if the path doesn't exist

Suggested change
if self.techui == Path("techui.yaml"):
self.techui = self._write_directory.joinpath("techui.yaml")
# Check if techui is default value and that it doesn't exist
if (
self.techui == self.__class__.__dataclass_fields__["techui"].default
and not self.techui.exists()
):
self.techui = self._write_directory.joinpath("techui.yaml")

assert test_json_map == example_json_map


def test_generate_json_map_embedded_screen(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to patch things like _parse_display_name() in these tests

json_map_generator.write_json_map()


def test_app():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is effectively the CLI test, it should only be in test_cli.py

Comment on lines +466 to +467
@app.callback(invoke_without_command=True)
def generate_jsonmap(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be changed to run with a command, such as techui-builder generate-jsonmap as part of the main Typer app created in __main__.py, instead of creating a second Typer app. You also then won't need to declare it in the main() function as a Typer Option.
You will need to see how to access the same typer.Typer app that was defined in __main__.py though from generate_jsonmap.py...

Suggested change
@app.callback(invoke_without_command=True)
def generate_jsonmap(
@app.command("generate-jsonmap")
def generate_jsonmap(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants