hiero-ledger / hiero-ledger/hiero-sdk-python

Add unit tests for the `Duration` class

Open
#2,557 13 comments 0 reactions 1 assignee Claimed by @Shr10122 View on GitHub
approved Good First Issue
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.