Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and refactor BaseStore.unparent #1171

Merged

Conversation

gycsaba96
Copy link
Contributor

I added unit tests for BaseStore.unparent and did a bit of refactoring. The only minor thing it revealed was that a KeyError was raised even when both IDs existed, but the corresponding items were not in a child-parent relation.

The main changes are as follows:

  • add unit tests for BaseStore.unparent,
  • use ValueError instead of KeyError when both parameters exist but are not in a child-parent relation,
  • simplify the algorithm.

Note: BaseStore.unparent doesn't actually need the parent_id as an extra input since it can be derived as child.parent.id. Unparenting is used in around 20 places, so the argument should be relatively easy to remove. Are there any plans or design decisions that could influence this?

- add unit tests for BaseStore.unparent
- use ValueError instead of KeyError when both parameters exist but
  are not in a child-parent relation
- simplify the algorithm
@gycsaba96 gycsaba96 force-pushed the test-basestore-unparent branch from ec818e4 to 93be36e Compare January 10, 2025 17:49
@diegogangl diegogangl added enhancement maintainability Automated tests suite, tooling, refactoring, or anything that makes it easier for developers labels Jan 13, 2025
@diegogangl
Copy link
Contributor

No plans or anything really, IIRC items didn't have a parent property (only children) in the very early versions of the new core. Less parameters is better though. Would you like to do it in this branch or another PR?

- remove the parent_id argument and adjust the code accordingly
- adjust the test cases
- (rename some test classes to keep things consistent)
@gycsaba96
Copy link
Contributor Author

Let's do it in one PR.

I removed the parent_id argument and adjusted the code and the tests. If the item has no parent, unparent has no effect. (I also renamed some test classes to keep things consistent.)

@diegogangl
Copy link
Contributor

Looks good, thanks!

@diegogangl diegogangl merged commit 3910d84 into getting-things-gnome:master Jan 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement maintainability Automated tests suite, tooling, refactoring, or anything that makes it easier for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants