-
Notifications
You must be signed in to change notification settings - Fork 4
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
NXPY-239: Fix tests cases on Python (Sourcery refactored) #276
NXPY-239: Fix tests cases on Python (Sourcery refactored) #276
Conversation
Sourcery AI seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
"User-Agent": app_name + "/" + version, | ||
"User-Agent": f"{app_name}/{version}", | ||
"Accept": "application/json, */*", | ||
} | ||
|
||
self.schemas = kwargs.get("schemas", "*") | ||
self.repository = kwargs.pop("repository", "default") | ||
self._session = requests.sessions.Session() | ||
self._session.hooks["response"] = [log_response] | ||
cookies = kwargs.pop("cookies", None) | ||
if cookies: | ||
if cookies := kwargs.pop("cookies", None): |
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.
Function NuxeoClient.__init__
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
data.update(params) | ||
data |= params | ||
|
||
url = self.api_path + "/search/lang/NXQL/execute" | ||
url = f"{self.api_path}/search/lang/NXQL/execute" |
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.
Function NuxeoClient.query
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
kwargs.update(self.client_kwargs) | ||
kwargs |= self.client_kwargs |
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.
Function NuxeoClient.request
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Merge dictionary updates via the union operator (
dict-assign-update-to-union
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
error_data.update(response.json()) | ||
error_data |= response.json() |
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.
Function NuxeoClient._handle_error
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
raise UnavailableBogusConvertor( | ||
e.message, options["converter"] if options["converter"] else "" | ||
) | ||
raise UnavailableBogusConvertor(e.message, options["converter"] or "") |
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.
Function API.convert
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} | ||
operation.input_obj = batch.get(0) | ||
operation.execute() | ||
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document") | ||
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document") |
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.
Function test_operation
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} | ||
operation.input_obj = batch.get(0) | ||
operation.execute(void_op=True) | ||
|
||
operation = server.operations.new("Document.Fetch") | ||
operation.params = {"value": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"value": f"{WORKSPACE_ROOT}/Document"} | ||
info = operation.execute() | ||
digest = info["properties"]["file:content"]["digest"] | ||
|
||
operation = server.operations.new("Blob.Get") | ||
operation.input_obj = WORKSPACE_ROOT + "/Document" | ||
operation.input_obj = f"{WORKSPACE_ROOT}/Document" |
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.
Function test_upload
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
operation.params = {"document": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"} | ||
operation.input_obj = batch.get(0) | ||
operation.execute(void_op=True) | ||
|
||
operation = server.operations.new("Document.Fetch") | ||
operation.params = {"value": WORKSPACE_ROOT + "/Document"} | ||
operation.params = {"value": f"{WORKSPACE_ROOT}/Document"} | ||
info = operation.execute() | ||
digest = info["properties"]["file:content"]["digest"] | ||
|
||
operation = server.operations.new("Blob.Get") | ||
operation.input_obj = WORKSPACE_ROOT + "/Document" | ||
operation.input_obj = f"{WORKSPACE_ROOT}/Document" |
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.
Function test_upload_several_callbacks
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "site/automation" | ||
self.url = f"{nuxeo_url}site/automation" |
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.
Function ResponseAutomation.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseChunkedContents.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseChunkedJsonContents.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseChunkedJsonContentsTooLong.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "json/cmis" | ||
self.url = f"{nuxeo_url}json/cmis" |
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.
Function ResponseCmis.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "nothing" | ||
self.url = f"{nuxeo_url}nothing" |
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.
Function ResponseEmpty.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "nothing" | ||
self.url = f"{nuxeo_url}nothing" |
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.
Function ResponseError409.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "8.3%20GiB.mxf" | ||
self.url = f"{nuxeo_url}8.3%20GiB.mxf" |
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.
Function ResponseMxf.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextError.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "small%20file.txt" | ||
self.url = f"{nuxeo_url}small%20file.txt" |
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.
Function ResponseTextOk.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
self.url = nuxeo_url + "big%20file.txt" | ||
self.url = f"{nuxeo_url}big%20file.txt" |
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.
Function ResponseTextTooLong.__init__
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
assert len(aces) in (2, 3) | ||
assert len(aces) in {2, 3} |
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.
Function test_fetch_acls
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.09%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Codecov ReportBase: 95.27% // Head: 95.33% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## wip-NXPY-239-Fix-tests-cases-on-Python #276 +/- ##
==========================================================================
+ Coverage 95.27% 95.33% +0.05%
==========================================================================
Files 26 26
Lines 1652 1649 -3
==========================================================================
- Hits 1574 1572 -2
+ Misses 78 77 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Pull Request #275 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
wip-NXPY-239-Fix-tests-cases-on-Python
branch, then run:Help us improve this pull request!