-
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) #278
NXPY-239: Fix tests cases on Python (Sourcery refactored) #278
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. |
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.10%.
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: 96.32% // Head: 96.31% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## wip-NXPY-239-Fix-tests-cases-on-Python #278 +/- ##
==========================================================================
- Coverage 96.32% 96.31% -0.01%
==========================================================================
Files 26 26
Lines 1633 1630 -3
==========================================================================
- Hits 1573 1570 -3
Misses 60 60
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. |
20587f9
to
e2d0e88
Compare
975e343
to
c7ea555
Compare
e2d0e88
to
ab92fe2
Compare
c7ea555
to
dcb28f1
Compare
ab92fe2
to
f4d7a70
Compare
dcb28f1
to
870ff51
Compare
f4d7a70
to
835dc3c
Compare
870ff51
to
18fb5a3
Compare
835dc3c
to
787eb05
Compare
18fb5a3
to
211dade
Compare
787eb05
to
4e9ede2
Compare
211dade
to
569e1ab
Compare
4e9ede2
to
d67d130
Compare
569e1ab
to
4fc4dd0
Compare
WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME | ||
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}" |
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.
Lines 4-4
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("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_digester
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
params={"document": WORKSPACE_ROOT + "/Document"}, | ||
params={"document": f"{WORKSPACE_ROOT}/Document"}, | ||
) | ||
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_execute
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() | ||
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
file_out = filename + ".dl" | ||
file_out = f"{filename}.dl" |
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 download_file
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
d67d130
to
f3c6477
Compare
4fc4dd0
to
ef81bb9
Compare
"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
)
nuxeo/documents.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
tests/test_log_response.py
Outdated
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
)
file_out = filename + ".dl" | ||
file_out = f"{filename}.dl" |
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 download_file
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
Pull Request #277 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!