-
Notifications
You must be signed in to change notification settings - Fork 28
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
Dynamically generate invalid config files in unit tests #220
Conversation
Signed-off-by: aadityasinha-dotcom <[email protected]>
Signed-off-by: Aaditya Sinha <[email protected]>
Signed-off-by: aadityasinha-dotcom <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #220 +/- ##
==========================================
+ Coverage 83.54% 83.72% +0.18%
==========================================
Files 34 34
Lines 2084 2108 +24
==========================================
+ Hits 1741 1765 +24
Misses 343 343
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@zFernand0 please review the changes |
tests/unit/test_zowe_core.py
Outdated
with open(self.original_file_path, 'r') as f: | ||
original_config = commentjson.load(f) | ||
original_config["$schema"] = "fixtures/invalid.zowe.schema.json" | ||
with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), 'w') as f: |
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 can't remove the files like invalid.zowe.config.json
or invalidUri.zowe.config.json
because other tests were failing
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.
The other tests are probably failing because the setUp
stage still expects the "invalid" files to exist:
zowe-client-python-sdk/tests/unit/test_zowe_core.py
Lines 201 to 204 in 66ceb94
self.fs.add_real_file(self.original_invalid_file_path) | |
self.fs.add_real_file(self.original_invalid_schema_file_path) | |
self.fs.add_real_file(self.original_invalidUri_file_path) | |
self.fs.add_real_file(self.original_invalidUri_schema_file_path) |
I think this can be fixed by moving the add_real_file
calls for invalid.zowe.config.json
inside the specific tests where the files are created.
tests/unit/test_zowe_core.py
Outdated
with open(self.original_file_path, 'r') as f: | ||
original_config = commentjson.load(f) | ||
original_config["$schema"] = "fixtures/invalid.zowe.schema.json" | ||
with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), 'w') as f: |
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.
The other tests are probably failing because the setUp
stage still expects the "invalid" files to exist:
zowe-client-python-sdk/tests/unit/test_zowe_core.py
Lines 201 to 204 in 66ceb94
self.fs.add_real_file(self.original_invalid_file_path) | |
self.fs.add_real_file(self.original_invalid_schema_file_path) | |
self.fs.add_real_file(self.original_invalidUri_file_path) | |
self.fs.add_real_file(self.original_invalidUri_schema_file_path) |
I think this can be fixed by moving the add_real_file
calls for invalid.zowe.config.json
inside the specific tests where the files are created.
Signed-off-by: aadityasinha-dotcom <[email protected]>
Signed-off-by: aadityasinha-dotcom <[email protected]>
Signed-off-by: Aaditya Sinha <[email protected]>
Signed-off-by: aadityasinha-dotcom <[email protected]>
with open(self.original_schema_file_path, "r") as f: | ||
original_schema = commentjson.load(f) | ||
with open(os.path.join(self.custom_dir, "invalid.zowe.schema.json"), "w") as f: | ||
commentjson.dump(original_schema, f) |
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 have also made the invalid.zowe.schema.json
, and made some changes to the config file dynamically
custom_dir = os.path.dirname(FIXTURES_PATH) | ||
custom_file_path = os.path.join(custom_dir, "zowe.config.json") | ||
os.chdir(custom_dir) | ||
with open(path_to_config, "r") as f: |
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 have also did the same thing for validate
method tests
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.
LGTM, thanks @aadityasinha-dotcom!
What It Does
Dynamically generate invalid config files in unit tests
How to Test
Review Checklist
I certify that I have:
Additional Comments