Skip to content
Open
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
7 changes: 7 additions & 0 deletions .trae/specs/hello-feature/checklist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- [x] Hello module structure is created with proper organization
- [x] Hello function returns "Hello" message when called without parameters
- [x] Hello function returns personalized greeting when name parameter is provided
- [x] Error handling is implemented for edge cases
- [x] Test file exists with comprehensive test coverage
- [x] All tests pass successfully
- [x] Code follows project conventions and style guidelines
31 changes: 31 additions & 0 deletions .trae/specs/hello-feature/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Hello Feature Spec

## Why
Implement a basic "hello" feature to demonstrate the spec-driven development workflow and establish a foundation for future features.

## What Changes
- Add a simple hello functionality that outputs a greeting message
- Create basic structure for handling greeting requests
- Implement configurable greeting messages

## Impact
- Affected specs: None (new feature)
- Affected code: New greeting module/component

## ADDED Requirements
### Requirement: Greeting Feature
The system SHALL provide a hello/greeting functionality that responds with a welcome message.

#### Scenario: Success case
- **WHEN** user requests a greeting
- **THEN** system returns a friendly "Hello" message

#### Scenario: Custom greeting
- **WHEN** user provides a name parameter
- **THEN** system returns a personalized greeting with the name

## MODIFIED Requirements
None

## REMOVED Requirements
None
18 changes: 18 additions & 0 deletions .trae/specs/hello-feature/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Tasks
- [x] Task 1: Create hello module structure
- [x] Subtask 1.1: Create directory structure for hello feature
- [x] Subtask 1.2: Add module initialization file

- [x] Task 2: Implement hello functionality
- [x] Subtask 2.1: Create hello function that returns greeting message
- [x] Subtask 2.2: Add support for optional name parameter
- [x] Subtask 2.3: Add basic error handling

- [x] Task 3: Add tests for hello feature
- [x] Subtask 3.1: Create test file for hello module
- [x] Subtask 3.2: Add test cases for basic greeting
- [x] Subtask 3.3: Add test cases for personalized greeting

# Task Dependencies
- [Task 2] depends on [Task 1]
- [Task 3] depends on [Task 2]
31 changes: 31 additions & 0 deletions pycchess/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# pycchess - just another chinese chess UI
# Copyright (C) 2011 - 2015 timebug

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""
The hello module provides basic greeting functionality for the pycchess application.

This module serves as an example module following the project's coding standards
and licensing requirements.
"""


def hello(name=None):
if name is None or not isinstance(name, str) or not name.strip():
return "Hello"
return "Hello, {}!".format(name.strip())
78 changes: 78 additions & 0 deletions pycchess/test_hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

# pycchess - just another chinese chess UI
# Copyright (C) 2011 - 2015 timebug

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""
Test module for the hello functionality.

This module contains unit tests for the hello function.
"""

from hello import hello


def test_hello_no_args():
result = hello()
assert result == "Hello", "hello() should return 'Hello'"


def test_hello_with_name():
result = hello("World")
assert result == "Hello, World!", "hello('World') should return 'Hello, World!'"


def test_hello_empty_string():
result = hello("")
assert result == "Hello", "hello('') should return 'Hello'"


def test_hello_none():
result = hello(None)
assert result == "Hello", "hello(None) should return 'Hello'"


def test_hello_whitespace_only():
result = hello(" ")
assert result == "Hello", "hello(' ') should return 'Hello'"


def test_hello_with_whitespace():
result = hello(" Alice ")
assert result == "Hello, Alice!", "hello(' Alice ') should return 'Hello, Alice!'"


if __name__ == "__main__":
test_hello_no_args()
print("test_hello_no_args passed")

test_hello_with_name()
print("test_hello_with_name passed")

test_hello_empty_string()
print("test_hello_empty_string passed")

test_hello_none()
print("test_hello_none passed")

test_hello_whitespace_only()
print("test_hello_whitespace_only passed")

test_hello_with_whitespace()
print("test_hello_with_whitespace passed")

print("\nAll tests passed!")