Skip to content

Conversation

@thecaptain789
Copy link

Summary

Adds comprehensive unit tests for the app.component.encrypt and app.component.time_friendly modules.

Changes

  • pytest configuration: Added pytest and pytest-cov as dev dependencies in pyproject.toml
  • Test structure: Created tests/app/component/ directory structure mirroring source code (per test: create pytest unit tests with clearer mirroring to original code path #1039)
  • conftest.py: Set up Python path for proper imports during testing
  • test_encrypt.py: 9 test cases covering:
    • Password hashing produces valid bcrypt hashes
    • Same password produces different hashes (salt verification)
    • Correct/incorrect password verification
    • Edge cases: None hash, unicode, special characters, long passwords
  • test_time_friendly.py: 11 test cases covering:
    • ISO and custom date format parsing
    • Invalid input handling (returns None)
    • Monday calculation for different days of week
    • Time/microsecond zeroing

Testing

cd server
uv pip install -e ".[dev]"
pytest tests/ -v

Related Issues

Contributes to #1039 (create pytest unit tests with clearer mirroring to original code path)

Checklist

  • Tests follow the tests/app/component/test_xxx.py naming convention
  • Comprehensive edge case coverage
  • Apache 2.0 license headers included

- Add pytest configuration to pyproject.toml with dev dependencies
- Create test structure mirroring app/component path (per eigent-ai#1039)
- Add comprehensive tests for password_hash and password_verify functions
- Add tests for to_date and monday_start_time utility functions
- Include conftest.py with path setup for proper imports
- Cover edge cases: unicode, special chars, None handling

Contributes to eigent-ai#1039
@Wendong-Fan
Copy link
Contributor

thanks @thecaptain789 's contribution!

@Wendong-Fan Wendong-Fan added this to the Sprint 13 milestone Feb 5, 2026
Copy link
Collaborator

@bytecii bytecii left a comment

Choose a reason for hiding this comment

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

In general LGTM. Left some comments.

# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
"""Unit tests for app.component.time_friendly module."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
"""Unit tests for app.component.encrypt module."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

from app.component.time_friendly import monday_start_time, to_date


class TestToDate:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just use def test_xxx as the tests are quite simple.

from app.component.encrypt import password_hash, password_verify


class TestPasswordHash:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just use def test_xxx as the tests are quite simple.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we also remove these init in the tests?

thecaptain789 and others added 2 commits February 6, 2026 14:17
- Convert class-based tests to simple function-based tests
- Remove unnecessary __init__.py from test directory
- Remove pytest import where not needed
- Remove __init__.py files from test directories
- Shorten test function names for clarity
@thecaptain789
Copy link
Author

Hi @bytecii, thanks for the review! I've addressed your feedback in the latest commits:

  • Removed the __init__.py files from test directories
  • Simplified test function names

Let me know if anything else is needed!

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.

3 participants