Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## Project Overview

This is a Python application managed with `uv`. The application prints
"Hello World" to standard output.
This is a Python application managed with `uv`. The application greets
the current user by name (e.g., "Hello Alice"). If the username cannot
be determined, it falls back to "Hello World".

## Build and Run

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# fullsend-python

A demo Python application that prints "Hello World".
A demo Python application that greets the current user by name. If the
username cannot be determined, it falls back to "Hello World".

## Prerequisites

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Application Requirements

1. The application prints "Hello World" to standard output.
1. The application greets the current user by name (e.g., "Hello Alice"). If the username cannot be determined, it falls back to "Hello World".
2. The application is managed using `uv` for dependency and lifecycle management.
3. Python 3.12 or later is required.

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/fullsend_python"]

[dependency-groups]
dev = [
"pytest>=9.1.1",
]
15 changes: 13 additions & 2 deletions src/fullsend_python/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
def main():
print("Hello World")
import getpass


def get_greeting_name() -> str:
"""Return the current username, or 'World' if it cannot be determined."""
try:
return getpass.getuser()
except Exception:
return "World"


def main() -> None:
print(f"Hello {get_greeting_name()}")


if __name__ == "__main__":
Expand Down
Empty file added tests/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from unittest.mock import patch

from fullsend_python.main import get_greeting_name, main


def test_get_greeting_name_returns_username():
with patch("fullsend_python.main.getpass.getuser", return_value="Alice"):
assert get_greeting_name() == "Alice"


def test_get_greeting_name_falls_back_to_world():
with patch("fullsend_python.main.getpass.getuser", side_effect=Exception):
assert get_greeting_name() == "World"


def test_main_greets_current_user(capsys):
with patch("fullsend_python.main.getpass.getuser", return_value="Alice"):
main()
assert capsys.readouterr().out.strip() == "Hello Alice"


def test_main_falls_back_to_world(capsys):
with patch("fullsend_python.main.getpass.getuser", side_effect=Exception):
main()
assert capsys.readouterr().out.strip() == "Hello World"
71 changes: 71 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading