Skip to content

Share API code fixes, refactoring, docstrings, tests#9

Merged
matejak merged 4 commits intoEnterpriseyIntranet:masterfrom
danil-topchiy:shares_fixes_docs_tests
Dec 26, 2018
Merged

Share API code fixes, refactoring, docstrings, tests#9
matejak merged 4 commits intoEnterpriseyIntranet:masterfrom
danil-topchiy:shares_fixes_docs_tests

Conversation

@danil-topchiy
Copy link

Fixed non working methods of Share API, added docs, tests

@danil-topchiy danil-topchiy force-pushed the shares_fixes_docs_tests branch from 4ea0977 to a5c2315 Compare December 22, 2018 21:12
@danil-topchiy
Copy link
Author

Hello @matejak
I decided to move methods which send requests to federated cloudshares from Share class to separate FederatedCloudShare class, because they're kind of separate from local shares logic.
Will push tests and docs for cloudshares in separate PR.

@danil-topchiy danil-topchiy changed the title WIP: Share API code fixes, docstrings, tests Share API code fixes, refactoring, docstrings, tests Dec 22, 2018
Copy link

@matejak matejak left a comment

Choose a reason for hiding this comment

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

Thank you for your work, it looks really good, especially those tests!

I have noticed some minor issues that were either present before and you just touched them, or that are also formal in their nature. Could you please take a look at them? Aside from those, the pull request is close to being merged.

self.query_components.append("reshares=true")
Args:
path (str): path to file/folder
reshares (bool): (optional) return not only the shares from the current user but all shares from the given file
Copy link

Choose a reason for hiding this comment

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

How is it with the bool type? We say that we expect bool, the default is None. Having to explicitly check for None makes the code a bit messy. Has None another meaning than False? This happens also to similar bool arguments later.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, None has different value than False. In most cases I convert True or False to string "true" or "false" and if it is None - this parameter not included in request.

Copy link
Author

Choose a reason for hiding this comment

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

Should I add to description that this param is either bool or None?

Copy link

Choose a reason for hiding this comment

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

No, that description would have to be repeated everywhere, and usage of tribools like this is common. It should go to developer's documentation when we have one :-)

NextCloud.py Outdated
public_upload = "true"
if (path is None or not isinstance(share_type, int)) \
or (share_type in [ShareType.GROUP, ShareType.USER, ShareType.FEDERATED_CLOUD_SHARE]
and share_with is None):
Copy link

Choose a reason for hiding this comment

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

I would prefer this condition to be extracted to a utility function for sake of readability (e.g. share_parameters_dont_make_sense(path, share_type, share_with).

Copy link
Author

Choose a reason for hiding this comment

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

Extracted it to staticmethod of Share class validate_share_parameters(path, share_type, share_with)

@matejak
Copy link

matejak commented Dec 26, 2018

Good job, thank you for the PR!

@matejak matejak merged commit b3f222c into EnterpriseyIntranet:master Dec 26, 2018
@danil-topchiy danil-topchiy deleted the shares_fixes_docs_tests branch June 15, 2019 16:22
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.

2 participants