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

NXPY-238: Fix issue with Self signed certificates (Sourcery refactored) #264

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Aug 31, 2022

Pull Request #263 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--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch, then run:

git fetch origin sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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-ai
Copy link
Contributor Author

sourcery-ai bot commented Aug 31, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.13%.

Quality metrics Before After Change
Complexity 3.95 ⭐ 3.89 ⭐ -0.06 👍
Method Length 62.33 🙂 62.30 🙂 -0.03 👍
Working memory 6.21 🙂 6.17 ⭐ -0.04 👍
Quality 72.50% 🙂 72.63% 🙂 0.13% 👍
Other metrics Before After Change
Lines 4592 4513 -79
Changed files Quality Before Quality After Quality Change
nuxeo/client.py 60.30% 🙂 60.68% 🙂 0.38% 👍
nuxeo/comments.py 80.38% ⭐ 80.60% ⭐ 0.22% 👍
nuxeo/documents.py 80.52% ⭐ 80.51% ⭐ -0.01% 👎
nuxeo/models.py 88.93% ⭐ 89.04% ⭐ 0.11% 👍
nuxeo/operations.py 50.78% 🙂 51.06% 🙂 0.28% 👍
nuxeo/uploads.py 66.55% 🙂 66.68% 🙂 0.13% 👍
nuxeo/utils.py 66.02% 🙂 65.82% 🙂 -0.20% 👎
tests/constants.py 95.67% ⭐ 95.51% ⭐ -0.16% 👎
tests/test_batchupload.py 58.77% 🙂 58.77% 🙂 0.00%
tests/test_document.py 68.93% 🙂 68.91% 🙂 -0.02% 👎
tests/test_log_response.py 93.50% ⭐ 93.41% ⭐ -0.09% 👎
tests/test_nuxeo.py 81.48% ⭐ 81.47% ⭐ -0.01% 👎
tests/test_repository.py 83.41% ⭐ 83.41% ⭐ 0.00%
tests/manual/many_small_files.py 82.28% ⭐ 82.25% ⭐ -0.03% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
nuxeo/client.py NuxeoClient.request 18 🙂 347 ⛔ 17 ⛔ 25.53% 😞 Try splitting into smaller methods. Extract out complex expressions
nuxeo/operations.py API.execute 12 🙂 253 ⛔ 23 ⛔ 29.83% 😞 Try splitting into smaller methods. Extract out complex expressions
nuxeo/operations.py API.save_to_file 19 😞 202 😞 15 😞 33.20% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tests/test_batchupload.py test_upload_several_callbacks 11 🙂 360 ⛔ 37.01% 😞 Try splitting into smaller methods
tests/test_batchupload.py test_idempotent_requests 11 🙂 346 ⛔ 37.43% 😞 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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
Copy link

codecov bot commented Aug 31, 2022

Codecov Report

Merging #264 (1b49366) into wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 (89e25dd) will decrease coverage by 0.04%.
The diff coverage is 90.47%.

@@                                                          Coverage Diff                                                           @@
##           wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2     #264      +/-   ##
======================================================================================================================================
- Coverage                                                                                               94.48%   94.44%   -0.05%     
======================================================================================================================================
  Files                                                                                                      29       29              
  Lines                                                                                                    1939     1925      -14     
======================================================================================================================================
- Hits                                                                                                     1832     1818      -14     
  Misses                                                                                                    107      107              
Flag Coverage Δ
unit 94.44% <90.47%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nuxeo/documents.py 92.95% <0.00%> (ø)
nuxeo/client.py 98.40% <100.00%> (-0.02%) ⬇️
nuxeo/comments.py 92.10% <100.00%> (ø)
nuxeo/models.py 93.05% <100.00%> (ø)
nuxeo/operations.py 100.00% <100.00%> (ø)
nuxeo/uploads.py 92.19% <100.00%> (-0.11%) ⬇️
nuxeo/utils.py 97.35% <100.00%> (-0.11%) ⬇️
nuxeo/handlers/s3.py 92.68% <0.00%> (-0.06%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@gitofanindya gitofanindya force-pushed the wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from dd4e532 to 6bc11b4 Compare August 31, 2022 08:25
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 3dc7abb to af2cff4 Compare August 31, 2022 08:27
@gitofanindya gitofanindya force-pushed the wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 6bc11b4 to 29a80d6 Compare August 31, 2022 09:59
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from af2cff4 to a795647 Compare August 31, 2022 10:01
@gitofanindya gitofanindya force-pushed the wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 29a80d6 to eea7138 Compare August 31, 2022 11:05
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch 3 times, most recently from 3a87552 to 8976964 Compare September 1, 2022 07:53
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 8976964 to fd6c4dd Compare September 8, 2022 09:59
Comment on lines -248 to +247
if SSL_VERIFY is False:
blob = batch.get(0, ssl_verify=False)
else:
blob = batch.get(0)
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_fetch refactored with the following changes:

Comment on lines -424 to +426
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
if SSL_VERIFY is False:
operation.input_obj = batch.get(0, ssl_verify=False)
else:
operation.input_obj = batch.get(0)
operation.execute()
if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -514 to +505
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -577 to +568
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -76 to +81
input_obj="doc:" + WORKSPACE_ROOT,
input_obj=f"doc:{WORKSPACE_ROOT}",
type="Note",
name=name,
properties=properties,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_create_bytes_warning refactored with the following changes:

Comment on lines -153 to +155
doc.move(WORKSPACE_ROOT + "/Test2", "new_name")
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name")
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_move refactored with the following changes:

self.url = nuxeo_url + "site/automation"
self.url = f"{nuxeo_url}site/automation"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

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:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'pageNo' type == int
# 'end' type == str
# unknown param
# 'pageSize' type == int
# 'file' type == str
# 'info' type == dict
# 'value' type == Sequence
# 'query' type == str
# 'validationMethod' type == str
# 'queryParams' type in [list, str]
# 'blockInheritance' type == boolean
# 'properties' type == dict
# 'target' type == list
# 'file' type in (Blob, str)
# 'queryParams' is also optional, None should be accepted
# 'value' type == str
# 'startPage', 'endPage' type == long

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

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:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

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:

@gitofanindya gitofanindya force-pushed the wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 6a7b19c to d44a4e0 Compare September 13, 2022 05:28
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from fd6c4dd to 1667c31 Compare September 13, 2022 05:29
Comment on lines -112 to +126
"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):
self._session.cookies = cookies
self._session.stream = True
self.client_kwargs = kwargs

self.ssl_verify_needed = True
if "verify" in kwargs.keys():
if "verify" in kwargs:
Copy link
Contributor Author

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:

Comment on lines -191 to +193
data.update(params)
data |= params

url = self.api_path + "/search/lang/NXQL/execute"
url = f"{self.api_path}/search/lang/NXQL/execute"
Copy link
Contributor Author

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:

kwargs.update(self.client_kwargs)
kwargs |= self.client_kwargs
Copy link
Contributor Author

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:

Comment on lines -425 to +424
error_data.update(response.json())
error_data |= response.json()
Copy link
Contributor Author

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:

kwargs.update(params)
kwargs |= params
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function API.get refactored with the following changes:

WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 5-5 refactored with the following changes:

operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -226 to +232
params={"document": WORKSPACE_ROOT + "/Document"},
params={"document": f"{WORKSPACE_ROOT}/Document"},
)

if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -248 to +247
if SSL_VERIFY is False:
blob = batch.get(0, ssl_verify=False)
else:
blob = batch.get(0)
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_fetch refactored with the following changes:

Comment on lines -424 to +426
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
if SSL_VERIFY is False:
operation.input_obj = batch.get(0, ssl_verify=False)
else:
operation.input_obj = batch.get(0)
operation.execute()
if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -514 to +505
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -577 to +568
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -76 to +81
input_obj="doc:" + WORKSPACE_ROOT,
input_obj=f"doc:{WORKSPACE_ROOT}",
type="Note",
name=name,
properties=properties,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_create_bytes_warning refactored with the following changes:

Comment on lines -153 to +155
doc.move(WORKSPACE_ROOT + "/Test2", "new_name")
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name")
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_move refactored with the following changes:

self.url = nuxeo_url + "site/automation"
self.url = f"{nuxeo_url}site/automation"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

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:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'properties' type == dict
# 'blockInheritance' type == boolean
# 'file' type == str
# 'pageSize' type == int
# 'queryParams' type in [list, str]
# 'queryParams' is also optional, None should be accepted
# 'startPage', 'endPage' type == long
# 'pageNo' type == int
# 'target' type == list
# 'value' type == Sequence
# 'validationMethod' type == str
# 'file' type in (Blob, str)
# 'value' type == str
# 'end' type == str
# unknown param
# 'info' type == dict
# 'query' type == str

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

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:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

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:

@gitofanindya gitofanindya force-pushed the wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from d44a4e0 to fc7c67c Compare September 13, 2022 07:52
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 1667c31 to 603736a Compare September 13, 2022 07:53
Comment on lines -112 to +126
"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):
self._session.cookies = cookies
self._session.stream = True
self.client_kwargs = kwargs

self.ssl_verify_needed = True
if "verify" in kwargs.keys():
if "verify" in kwargs:
Copy link
Contributor Author

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:

Comment on lines -191 to +193
data.update(params)
data |= params

url = self.api_path + "/search/lang/NXQL/execute"
url = f"{self.api_path}/search/lang/NXQL/execute"
Copy link
Contributor Author

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:

kwargs.update(self.client_kwargs)
kwargs |= self.client_kwargs
Copy link
Contributor Author

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:

Comment on lines -425 to +424
error_data.update(response.json())
error_data |= response.json()
Copy link
Contributor Author

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:

kwargs.update(params)
kwargs |= params
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function API.get refactored with the following changes:

WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 5-5 refactored with the following changes:

operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -226 to +232
params={"document": WORKSPACE_ROOT + "/Document"},
params={"document": f"{WORKSPACE_ROOT}/Document"},
)

if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -248 to +247
if SSL_VERIFY is False:
blob = batch.get(0, ssl_verify=False)
else:
blob = batch.get(0)
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_fetch refactored with the following changes:

Comment on lines -424 to +426
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
if SSL_VERIFY is False:
operation.input_obj = batch.get(0, ssl_verify=False)
else:
operation.input_obj = batch.get(0)
operation.execute()
if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -514 to +505
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -577 to +568
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -76 to +81
input_obj="doc:" + WORKSPACE_ROOT,
input_obj=f"doc:{WORKSPACE_ROOT}",
type="Note",
name=name,
properties=properties,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_create_bytes_warning refactored with the following changes:

Comment on lines -153 to +155
doc.move(WORKSPACE_ROOT + "/Test2", "new_name")
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name")
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_move refactored with the following changes:

self.url = nuxeo_url + "site/automation"
self.url = f"{nuxeo_url}site/automation"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

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:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'blockInheritance' type == boolean
# 'end' type == str
# 'file' type in (Blob, str)
# 'pageSize' type == int
# 'info' type == dict
# 'file' type == str
# 'target' type == list
# 'validationMethod' type == str
# 'value' type == Sequence
# 'value' type == str
# 'startPage', 'endPage' type == long
# 'properties' type == dict
# 'queryParams' type in [list, str]
# 'pageNo' type == int
# unknown param
# 'queryParams' is also optional, None should be accepted
# 'query' type == str

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

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:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

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:

@gitofanindya gitofanindya force-pushed the wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from fc7c67c to 89e25dd Compare September 13, 2022 08:13
@sourcery-ai sourcery-ai bot force-pushed the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch from 603736a to 1b49366 Compare September 13, 2022 08:14
Comment on lines -112 to +126
"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):
self._session.cookies = cookies
self._session.stream = True
self.client_kwargs = kwargs

self.ssl_verify_needed = True
if "verify" in kwargs.keys():
if "verify" in kwargs:
Copy link
Contributor Author

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:

Comment on lines -191 to +193
data.update(params)
data |= params

url = self.api_path + "/search/lang/NXQL/execute"
url = f"{self.api_path}/search/lang/NXQL/execute"
Copy link
Contributor Author

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:

kwargs.update(self.client_kwargs)
kwargs |= self.client_kwargs
Copy link
Contributor Author

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:

Comment on lines -425 to +424
error_data.update(response.json())
error_data |= response.json()
Copy link
Contributor Author

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:

kwargs.update(params)
kwargs |= params
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function API.get refactored with the following changes:

WORKSPACE_TEST = WORKSPACE_ROOT + "/" + WORKSPACE_NAME
WORKSPACE_TEST = f"{WORKSPACE_ROOT}/{WORKSPACE_NAME}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 5-5 refactored with the following changes:

operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -226 to +232
params={"document": WORKSPACE_ROOT + "/Document"},
params={"document": f"{WORKSPACE_ROOT}/Document"},
)

if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -248 to +247
if SSL_VERIFY is False:
blob = batch.get(0, ssl_verify=False)
else:
blob = batch.get(0)
blob = batch.get(0, ssl_verify=False) if SSL_VERIFY is False else batch.get(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_fetch refactored with the following changes:

Comment on lines -424 to +426
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
if SSL_VERIFY is False:
operation.input_obj = batch.get(0, ssl_verify=False)
else:
operation.input_obj = batch.get(0)
operation.execute()
if SSL_VERIFY is False:
doc = server.documents.get(
path=WORKSPACE_ROOT + "/Document", ssl_verify=False
)
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document", ssl_verify=False)
else:
doc = server.documents.get(path=WORKSPACE_ROOT + "/Document")
doc = server.documents.get(path=f"{WORKSPACE_ROOT}/Document")
Copy link
Contributor Author

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:

Comment on lines -514 to +505
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -577 to +568
operation.params = {"document": WORKSPACE_ROOT + "/Document"}
operation.params = {"document": f"{WORKSPACE_ROOT}/Document"}
Copy link
Contributor Author

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:

Comment on lines -76 to +81
input_obj="doc:" + WORKSPACE_ROOT,
input_obj=f"doc:{WORKSPACE_ROOT}",
type="Note",
name=name,
properties=properties,
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_create_bytes_warning refactored with the following changes:

Comment on lines -153 to +155
doc.move(WORKSPACE_ROOT + "/Test2", "new_name")
assert WORKSPACE_ROOT + "/Test2/new_name" in doc.path
doc.move(f"{WORKSPACE_ROOT}/Test2", "new_name")
assert f"{WORKSPACE_ROOT}/Test2/new_name" in doc.path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_document_move refactored with the following changes:

self.url = nuxeo_url + "site/automation"
self.url = f"{nuxeo_url}site/automation"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "small%20file.txt"
self.url = f"{nuxeo_url}small%20file.txt"
Copy link
Contributor Author

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:

self.url = nuxeo_url + "big%20file.txt"
self.url = f"{nuxeo_url}big%20file.txt"
Copy link
Contributor Author

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:

Comment on lines -18 to +30
@pytest.mark.parametrize(
"method, params, is_valid",
[
# 'file' type in (Blob, str)
("Document.SetBlob", {"file": Blob()}, True),
("Document.SetBlob", {"file": "test.txt"}, True),
("Document.SetBlob", {"file": 0}, False),
# 'blockInheritance' type == boolean
(
@pytest.mark.parametrize("method, params, is_valid", [("Document.SetBlob", {"file": Blob()}, True), ("Document.SetBlob", {"file": "test.txt"}, True), ("Document.SetBlob", {"file": 0}, False), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": False},
True,
),
(
), (
"Document.AddPermission",
{"permission": "Read", "blockInheritance": "false"},
False,
),
# 'end' type == str
("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True),
("Document.AddPermission", {"permission": "Read", "end": True}, False),
# 'value' type == str
("Document.Fetch", {"value": "test.txt"}, True),
("Document.Fetch", {"value": True}, False),
# 'target' type == list
("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True),
("Document.MultiPublish", {"target": 0}, False),
# 'pageNo' type == int
("Audit.Query", {"query": "test", "pageNo": 100}, True),
# 'pageSize' type == int
("Audit.Query", {"query": "test", "pageNo": "test"}, False),
("Document.Query", {"query": "test", "pageSize": 10}, True),
("Document.Query", {"query": "test", "pageSize": "test"}, False),
# 'startPage', 'endPage' type == long
("PDF.ExtractPages", {"startPage": 1, "endPage": int(2)}, True),
("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False),
# 'info' type == dict
("User.Invite", {"info": {"username": "test"}}, True),
("User.Invite", {"info": 0}, False),
# 'properties' type == dict
(
), ("Document.AddPermission", {"permission": "Read", "end": "01-01-2018"}, True), ("Document.AddPermission", {"permission": "Read", "end": True}, False), ("Document.Fetch", {"value": "test.txt"}, True), ("Document.Fetch", {"value": True}, False), ("Document.MultiPublish", {"target": ["test1.txt", "test2.txt"]}, True), ("Document.MultiPublish", {"target": 0}, False), ("Audit.Query", {"query": "test", "pageNo": 100}, True), ("Audit.Query", {"query": "test", "pageNo": "test"}, False), ("Document.Query", {"query": "test", "pageSize": 10}, True), ("Document.Query", {"query": "test", "pageSize": "test"}, False), ("PDF.ExtractPages", {"startPage": 1, "endPage": 2}, True), ("PDF.ExtractPages", {"startPage": "test", "endPage": "test"}, False), ("User.Invite", {"info": {"username": "test"}}, True), ("User.Invite", {"info": 0}, False), (
"Document.Create",
{"type": "Document", "properties": {"dc:title": "test"}},
True,
),
("Document.Create", {"type": "Document", "properties": 0}, False),
# 'file' type == str
("Blob.Create", {"file": "test.txt"}, True),
("Blob.Create", {"file": 0}, False),
# 'value' type == Sequence
("Document.SetProperty", {"xpath": "test", "value": "test"}, True),
("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True),
("Document.SetProperty", {"xpath": "test", "value": 0}, False),
# 'query' type == str
("Document.Query", {"query": "test"}, True),
("Document.Query", {"query": 0}, False),
# 'queryParams' type in [list, str]
("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True),
("Document.Query", {"query": "test", "queryParams": "test"}, True),
("Document.Query", {"query": "test", "queryParams": 0}, False),
# 'queryParams' is also optional, None should be accepted
("Document.Query", {"query": "test", "queryParams": None}, True),
# 'validationMethod' type == str
("User.Invite", {"validationMethod": "test"}, True),
("User.Invite", {"validationMethod": 0}, False),
# unknown param
("Document.Query", {"alien": "alien"}, False),
],
)
), ("Document.Create", {"type": "Document", "properties": 0}, False), ("Blob.Create", {"file": "test.txt"}, True), ("Blob.Create", {"file": 0}, False), ("Document.SetProperty", {"xpath": "test", "value": "test"}, True), ("Document.SetProperty", {"xpath": "test", "value": [0, 1, 2]}, True), ("Document.SetProperty", {"xpath": "test", "value": 0}, False), ("Document.Query", {"query": "test"}, True), ("Document.Query", {"query": 0}, False), ("Document.Query", {"query": "test", "queryParams": ["a", "b", "c"]}, True), ("Document.Query", {"query": "test", "queryParams": "test"}, True), ("Document.Query", {"query": "test", "queryParams": 0}, False), ("Document.Query", {"query": "test", "queryParams": None}, True), ("User.Invite", {"validationMethod": "test"}, True), ("User.Invite", {"validationMethod": 0}, False), ("Document.Query", {"alien": "alien"}, False)])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_check_params refactored with the following changes:

This removes the following comments ( why? ):

# 'queryParams' is also optional, None should be accepted
# unknown param
# 'end' type == str
# 'blockInheritance' type == boolean
# 'queryParams' type in [list, str]
# 'value' type == str
# 'pageSize' type == int
# 'file' type == str
# 'target' type == list
# 'query' type == str
# 'properties' type == dict
# 'startPage', 'endPage' type == long
# 'value' type == Sequence
# 'file' type in (Blob, str)
# 'info' type == dict
# 'validationMethod' type == str
# 'pageNo' type == int

Comment on lines -284 to +228
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_info_bad_response refactored with the following changes:

Comment on lines -315 to +259
rsps.add(responses.GET, server.client.host + "json/cmis", body="...")
rsps.add(responses.GET, f"{server.client.host}json/cmis", body="...")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function test_server_version_bad_response_from_server_info refactored with the following changes:

assert len(aces) in (2, 3)
assert len(aces) in {2, 3}
Copy link
Contributor Author

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:

file_out = filename + ".dl"
file_out = f"{filename}.dl"
Copy link
Contributor Author

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:

@sourcery-ai sourcery-ai bot closed this Oct 12, 2022
@sourcery-ai sourcery-ai bot deleted the sourcery/wip-NXPY--Investigate-the-login-issue-with-SSL-and-without-legacy-authentication-check-i.e.-oauth2 branch October 12, 2022 10:42
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.

None yet

1 participant