-
Notifications
You must be signed in to change notification settings - Fork 141
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
FEAT: Add AEDT File Management tests #5879
base: main
Are you sure you want to change the base?
Conversation
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (72.00%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #5879 +/- ##
==========================================
+ Coverage 84.92% 84.99% +0.07%
==========================================
Files 161 161
Lines 62156 62179 +23
==========================================
+ Hits 52785 52851 +66
+ Misses 9371 9328 -43 🚀 New features to boost your workflow:
|
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.
Overall LGTM but I left a few minor comments. Thanks for making the migration @Samuelopez-ansys and thanks for the propositio @Marwane-20
@@ -47,11 +49,17 @@ def read_info_fromcsv(projdir, name): | |||
list |
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.
Could we deprecate this method and create a new one (with the same content) named read_info_form_csv
?
content = content_bytes.decode("utf-8") | ||
except UnicodeDecodeError: | ||
content = content_bytes.decode("latin1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would revert to the previous statement unless we are sure that our users have data that can be decoded with "utf-8"
or "latin1
. @Samuelopez-ansys Do you know to what extent are we supposed to be compatible with other encoding ? Are we limited to "utf-8"
? If that's the case, we can only try that encoding.
|
||
filename = projdir + "//" + name | ||
# Construct the filename using pathlib. | ||
filename = str(Path(projdir) / name) | ||
listmcad = [] | ||
with open_file(filename, "rb") as csvfile: |
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.
Isn't open_file
compatible with Path
now ?
view_str = u"Drawings[" + str(len(solid_list)) + u": " + str(solid_list).strip("[") | ||
s = pattern.sub(r"\1" + view_str + r"\3", content) |
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.
view_str = u"Drawings[" + str(len(solid_list)) + u": " + str(solid_list).strip("[") | |
s = pattern.sub(r"\1" + view_str + r"\3", content) | |
view_str = f"Drawings[{len(solid_list)}: {str(solid_list).strip('[')}" | |
s = pattern.sub(fr"\1{view_str}\3", content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think u"..."
are needed
logging.error("change_objects_visibility: Error encountered - %s", e) | ||
return False |
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.
logging.error("change_objects_visibility: Error encountered - %s", e) | |
return False | |
raise AEDTRuntimeError("Failed to restrict visibility to specified solids.") from e |
I think that this will required an additional import
logging.error("change_objects_visibility: Project %s is still locked.", origfile) | ||
return False |
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.
logging.error("change_objects_visibility: Project %s is still locked.", origfile) | |
return False | |
raise AEDTRuntimeError(f"Project {origfile} is still locked.") |
logging.error("change_model_orientation: Error encountered - %s", e) | ||
return False |
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.
logging.error("change_model_orientation: Error encountered - %s", e) | |
return False | |
raise AEDTRuntimeError("Failed to change model orientation.") from e |
logging.error("change_model_orientation: Project %s is still locked.", origfile) | ||
return False |
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.
logging.error("change_model_orientation: Project %s is still locked.", origfile) | |
return False | |
raise AEDTRuntimeError(f"Project {origfile} is still locked.") |
|
||
# Call the function. | ||
result = clean_proj_folder(proj_dir.as_posix(), "project") | ||
assert result is True |
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.
assert result is True | |
assert result |
@@ -0,0 +1,123 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this file test should be moved to tests/unit since we are not testing the method with a subset of other modules / classes
solid_list = ["solid1", "solid2"] | ||
result = change_objects_visibility(str(origfile), solid_list) | ||
# Since the regex is applied on bytes, an error occurs and the function returns False. | ||
assert result is False |
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.
assert result is False | |
assert not result |
|
||
result = change_model_orientation(str(origfile), "+X") | ||
# The function returns False on error. | ||
assert result is False |
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.
assert result is False | |
assert not result |
Description
Please provide a brief description of the changes made in this pull request.
Issue linked
Close #5756
Checklist