-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature/batch operation #20
Changes from 3 commits
b4bcaf2
6ffef46
505bf18
ccf69f2
3d31199
7c5b013
ca9c971
c916f79
ce79109
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |
|
||
## [Unreleased] | ||
### Added | ||
- Batch of package names reservation | ||
- testcase for batch package name reservation in `test_reserver.py` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this line. Tests are implicitly logged with the main feature. |
||
### Changed | ||
- `README.md` modified | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
## [0.1] - 2024-02-07 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,19 @@ def __init__(self, api_token, test_pypi=False): | |
self.password = api_token | ||
self.test_pypi = test_pypi | ||
|
||
|
||
|
||
def batch_upload_to_pypi(self, *names): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer the input to be listed. I think that's a more pythonic solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with this syntax, the user can do both of these: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not true I guess. If you use the array call version it tries to call the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok sure I will investigate this, I think we both do have same intension, sure, I will take care of. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right, thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. def batch_upload(self, *names):
"""
Upload batch of package names to PyPI.
:param names: packages' names
:type names: vararg
:return: int(number of successfully reserved names)
"""
reserved_successfully = 0
for name in names:
if isinstance(name, list):
reserved_successfully += self.batch_upload(*name)
else:
is_reserved = self.upload(name)
if is_reserved:
reserved_successfully += 1
return reserved_successfully Happy sir? tests also updated accordingly |
||
""" | ||
Upload batch of package names to PyPI. | ||
|
||
:param names: packages' names | ||
:type names: vararg | ||
:return: None | ||
""" | ||
for name in names: | ||
self.upload_to_pypi(name) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you accept my comments on returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, in my opinion, it is way too geeky, I prefer to return the number of actually reserved names here. |
||
def upload_to_pypi(self, package_name): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, I should think in more depth about what is False or what is True in this context, but ok I will return sth, maybe the number of names got reserved in this case instead of an ambitious boolean value. |
||
""" | ||
Upload a template package to pypi or test_pypi. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,12 @@ def test_package_exists(): | |
uploader = Uploader(test_pypi_token, test_pypi= True) | ||
assert uploader.upload_to_pypi("numpy") == False | ||
|
||
def test_batch_packages_names(): | ||
# test batch of package names | ||
uploader = Uploader(test_pypi_token, test_pypi= True) | ||
uploader.batch_upload_to_pypi("numpy", "scikit-learn") | ||
assert True == True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you accept my comment on returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again with the number of actual names reserved, I can handle associated test cases better and ok sure I will. |
||
|
||
def test_valid_package_invalid_credentials(): | ||
# test not reserved name -> wrong credentials | ||
wrong_pypi_token = "pypi-wrong-api-token" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer something more to-the-point for the user like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok