hiero-ledger / hiero-ledger/hiero-sdk-python
Add unit tests for the `Duration` class
- Dominant language
- Python
- Stars
- 63
- Forks
- 298
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 38
Description
### ππ₯ Newcomer Friendly
Welcome! This is a **[Good First Issue](https://github.com/issues?q=is%3Aopen%20is%3Aissue%20org%3Ahiero-ledger%20archived%3Afalse%20no%3Aassignee%20(label%3A%22good%20first%20issue%22%20OR%20label%3A%22skill%3A%20good%20first%20issue%22)%20(repo%3Ahiero-ledger%2Fhiero-sdk-cpp%20OR%20repo%3Ahiero-ledger%2Fhiero-sdk-swift%20OR%20repo%3Ahiero-ledger%2Fhiero-sdk-python%20OR%20repo%3Ahiero-ledger%2Fhiero-sdk-js%20OR%20repo%3Ahiero-ledger%2Fhiero-website))** designed to be approachable to brand-new contributors.
π **When this issue is complete, you will have:**
β
Learned how to fork and navigate the codebase
β
Learned our contribution workflow
β
Implemented a real change to the SDK
### π Problem Description
`Duration` is a small public value object (exported from `hiero_sdk_python/__init__.py`) that wraps a
number of seconds and converts to and from the protobuf `Duration` message. It is used wherever the
SDK needs a time span for example the auto-renew period on topics and accounts.
There is no `tests/unit/duration_test.py`. Nothing currently verifies that:
- passing a non-integer to `Duration(...)` raises the `TypeError` its `__post_init__` promises,
- `_to_proto()` / `_from_proto()` round-trip correctly,
- `__str__`, `__repr__` and `__eq__` behave as written (`__eq__` returns `False` β not
`NotImplemented` β for non-`Duration` objects, which is worth pinning down in a test).
Files to look at:
- `src/hiero_sdk_python/Duration.py` the code under test (37 lines; note the capital-D filename)
- `tests/unit/timestamp_test.py` an existing test for the closest sibling type; good reference for
how proto conversion is tested here
- `tests/unit/supply_type_test.py` reference for file layout and style
### π‘ Solution
Add `tests/unit/duration_test.py` covering construction, validation, protobuf conversion in both
directions, and the dunder methods. Tests only β no production code changes.
Please write the tests to describe the code's **current** behaviour. If you spot something that looks
questionable, don't change it: leave a comment on the issue and we'll open a separate issue for it.
### π οΈ Implementation Steps
### π§ Good First Issue Developers β Prerequisites & Expectations
> [!IMPORTANT]
> **This issue does not require prior domain knowledge.**
>
> - No Hiero or Hedera experience needed
> - No distributed ledger background required
> - **Beginner Programming is sufficient**
> [!NOTE]
> β±οΈ **Typical time to complete:** ~1 Day / ~4 hours (including set-up)
> π§© **Difficulty:** Small, well-contained change
> π **Best for:** New contributors
π€ AI Usage Policy
- Good First Issues are open for humans, AI bot-authored PRs will be rejected.
- Refer to our set-up and workflow guides, AI may make mistakes.
> [!WARNING]
> We expect pull requests to use our workflow and meet the quality standards outlined in this issue.
### π Step-by-Step Setup Procedure
- [ ] Visual Studio (VS) Code: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#visual-studio-code)
- [ ] GitHub Desktop: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#github-desktop)
- [ ] Hedera Testnet Account with root .env file: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#2-setting-up-a-portal-account)
- [ ] Create a GPG key linked to GitHub: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#3-set-up-a-gpg-key-for-signing)
- [ ] **Fork** Create an online and local copy of the repository: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#4-fork-the-repository)
- [ ] **Connect** origin with upstream: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#5-connect-your-origin-with-upstream)
- [ ] **Install Packages** and protobufs: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#6-install-packages-and-protobufs)
- [ ] **Windows users:** see the [Windows Setup Guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/setup_windows.md) for platform-specific installation steps.
- [ ] **Sync Main** pull any recent upstream changes: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#7-sync-main)
- [ ] **Pre-commit Hooks:** Setup pre-commit hooks for linting and formatting: [Guide](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/docs/sdk_developers/setup.md#pre-commit-tool-setup)
You are set up! π
### π Step-by-step workflow guide
#### β Get ready
- [ ] **Claim the issue:** comment `/assign`: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#1-get-assigned-to-an-issue). Pull requests created without being assigned will be automatically closed.
- [ ] **Double check the Issue and AI plan:** carefully re-read the issue description and any AI plan below
- [ ] **Ask questions early:** ask on [Discord](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/discord.md), and the `@good_first_issue_support_team` (setup and workflow help)
- [ ] **Sync Main** pull any recent upstream changes: [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-setup.md#7-sync-main)
- [ ] π‘ Tip: Before coding, you are free to leave a short comment describing what you plan to change. We'll confirm you're on the right track.
#### π οΈ Solve the Issue
- [ ] **Create a branch from `main`:** [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#2-create-a-branch)
- [ ] **Implement the solution**: follow the implementation steps in the issue description.
- [ ] **Commit with Conventional format and DCO, GPG signing:** commit changes using: `git commit -S -s -m "chore: your message"`, [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#3-commit-your-changes)
#### π Create the pull request
- [ ] **Push your commits:** push your branch to your fork `git push origin your-branch-name` [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#5-submitting-a-pull-request)
- [ ] **Open a pull request:** [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#5-submitting-a-pull-request)
- [ ] **Complete the PR description:** briefly describe your changes, [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#5-submitting-a-pull-request)
- [ ] **Link the Issue:** link the issue the PR solves in the PR description, [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/contributor-workflow.md#5-submitting-a-pull-request). Pull requests created without a linked issue will be automatically closed.
- [ ] **Submit the pull request:** click `**Create pull request**` and `Ready to Review` π
### β PR Quality Checklist
To be able to close this issue, the following criteria must be met:
Workflow:
- [ ] I have worked from a branch that is up to date with main
- [ ] I have not made changes outside the scope of this issue
- [ ] My commits are signed: `git commit -S -s -m "chore: description"` β [Signing guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/signing.md)
- [ ] I linked the issue in my PR description using `Fixes #issue_number` to automatically close it when merged
- [ ] I have applied appropriate linting, code quality, and formatting tools used in this repo (if applicable).
- [ ] I have installed and run **pre-commit** hooks to ensure code quality and formatting.
Issue Requirement:
- [ ] The issue is solved: I've carefully read and implemented the issue requirements
---
### π€ What to expect after submitting a PR
Once you open a pull request, here's what happens next.
**π€ 1. Automated checks**
Automated checks will run and all must pass before merging.
Open any failed check at the bottom of the PR to see details. Ask for help if you don't understand a failure or how to fix it.
**π 2. Initial Team review**
Once tests pass, a team member will check if your PR follows the workflow.
**β
3. Team review**
Once your tests pass and the workflow is followed, a team member will review the implementation.
You may be asked to make changes or your PR may be approved.
Approved PRs are usually merged within **one day**.
**π Merge conflicts (sometimes)**
Conflicts can happen and are normal as the SDK updates. Resolve using this [Guide](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/merge_conflicts.md)
> [!TIP]
> **Follow the workflow and double check your work**
> This is the best way to ensure a fast review and merge process.
---
### π§ Getting help if you're stuck
**π Stuck?**
> [!TIP]
>
> - Comment on this issue and ask maintainers or tag `@good_first_issue_support_team`
>
#### Other Resources:
- [New Starter Docs (Signing, Rebasing, Changelog, Merge Conflicts, Workflow, Setup)](https://github.com/hiero-ledger/sdk-collaboration-hub/tree/main/guides/issue-progression/for-developers)
- [All Things Github Workflows](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/github-action-workflows.md)
- [Community Calls](https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week)
- [Discord](https://github.com/hiero-ledger/sdk-collaboration-hub/blob/main/guides/issue-progression/for-developers/discord.md)
---
Contributor guide
Assessment
This issue has not been assessed yet.