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

Flexible working directory #31

Open
wants to merge 72 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
2cfdbca
Commit test for Issue 16
Fan-Feng Mar 1, 2024
c47eca9
update for Issue16
Fan-Feng Mar 5, 2024
1b19f89
Add ctest for Linux/Windows Working path
Fan-Feng Mar 12, 2024
ab43881
add check for working directory format
Fan-Feng Mar 13, 2024
1c68726
add check for Working path format
Fan-Feng Mar 18, 2024
3fe5757
fix formatting error
Fan-Feng Mar 20, 2024
4476be7
fix formatting error
Fan-Feng Mar 20, 2024
1f898ee
fix formatting error
Fan-Feng Mar 20, 2024
fdc0805
fix formatting error
Fan-Feng Mar 20, 2024
392e875
fix formatting error
Fan-Feng Mar 20, 2024
c715679
fix formatting error
Fan-Feng Mar 20, 2024
30905af
fix formatting error
Fan-Feng Mar 20, 2024
31bf31c
add unit test
Fan-Feng Mar 22, 2024
d44100d
add unittest if path does not exist
Fan-Feng Mar 22, 2024
b61746f
unittest for flexible calling
Fan-Feng Mar 22, 2024
bdd6f6a
fix formatting error
Fan-Feng Mar 22, 2024
c3545ed
Update unittest for flexible calling
Fan-Feng Mar 25, 2024
fc94687
add a minimal case for unit test
Fan-Feng Mar 25, 2024
3d96768
fix unit test
Fan-Feng Mar 25, 2024
823bcde
fix unit test
Fan-Feng Mar 25, 2024
5c9568c
Fix unitttest
Fan-Feng Mar 25, 2024
702c623
fix unittest
Fan-Feng Mar 25, 2024
321e939
fix unittest
Fan-Feng Mar 25, 2024
0c4bc3c
test unittest
Fan-Feng Mar 25, 2024
74bcf94
Test for unit test 1
Fan-Feng Mar 25, 2024
cc7e1b4
Fix unittest
Fan-Feng Mar 25, 2024
600cdf3
Fix unittest
Fan-Feng Mar 25, 2024
84fb6bd
Fix unit test
Fan-Feng Mar 25, 2024
0b139bb
Test1
Fan-Feng Mar 25, 2024
0726e4f
Test1
Fan-Feng Mar 25, 2024
79df117
Fix unittest
Fan-Feng Mar 25, 2024
95ffdff
Unit test 1
Fan-Feng Mar 25, 2024
ca55f31
Fix unittest
Fan-Feng Mar 25, 2024
1dc278e
Unit test 1
Fan-Feng Mar 25, 2024
60aa878
Move flexible calling to a new folder
Fan-Feng Mar 25, 2024
6d2dec0
Update unittest for flexible calling
Fan-Feng Mar 25, 2024
7ed2796
clean redundant comments
Fan-Feng Apr 16, 2024
1ac2802
clean redundant comments
Fan-Feng Apr 16, 2024
273bb0f
create json schemas for library and verification case
Fan-Feng May 8, 2024
7cd8981
Create a new directory if it doesn't exist
Fan-Feng May 15, 2024
e8b44fb
put the whole working dir logic into a dedicate
Fan-Feng May 15, 2024
04f86d4
fix unittest error
Fan-Feng May 15, 2024
cb8d898
Merge branch 'CODEVERIFY-16' of https://github.com/pnnl/ConStrain int…
Fan-Feng May 15, 2024
bc8dc9b
rm json schema
Fan-Feng May 15, 2024
e2248e9
Fix unittest error
Fan-Feng May 16, 2024
519925a
Black formatting
Fan-Feng May 16, 2024
67f0d7b
black formatting--weird. This file is already reformatted on my compu…
Fan-Feng May 16, 2024
29c5bc5
add unittest for absolute path
Fan-Feng May 17, 2024
58c647d
Add checks based on Jerry's comments
May 30, 2024
79f1d7e
Fix unittest error
Fan-Feng May 30, 2024
af7a39b
Black format
Fan-Feng May 30, 2024
32ec918
Fix unittest issue
Fan-Feng May 30, 2024
47a91ae
revise json file
Fan-Feng May 30, 2024
4bfbe9b
fix unittest
Fan-Feng May 30, 2024
6746efb
Add unittest for invalid working directories
Fan-Feng May 30, 2024
fa4c415
add chc for linux-format path
Fan-Feng May 30, 2024
77008ef
add check for Win-format path
Fan-Feng May 30, 2024
1d31cfe
fix windows_format path
Fan-Feng May 31, 2024
82f0e12
Fix windows format path
Fan-Feng May 31, 2024
e7d832e
Add checfr escape sequence path
Fan-Feng May 31, 2024
ec858b1
add checks for paths with space
Fan-Feng May 31, 2024
c9b1450
Add check for path with space
Fan-Feng May 31, 2024
aa7bf8e
add check for absolute path
Fan-Feng May 31, 2024
843d7d7
fix check for absolute path
Fan-Feng May 31, 2024
4b4911d
Fix uittest for Absolute path
Fan-Feng May 31, 2024
6434fc9
Black formatting
Fan-Feng May 31, 2024
dbee11f
Add unittest for Invalid string with escape sequence path
Fan-Feng May 31, 2024
c6e7f93
Fix unittest for invalid strings with escape sequences
Fan-Feng May 31, 2024
d7ae45f
Test escape sequence
Fan-Feng May 31, 2024
b1ccf7c
add test for path that does not exist
Fan-Feng May 31, 2024
8348e5b
Black formatting
Fan-Feng May 31, 2024
6e0caa7
add unit test for path without \ or /
Fan-Feng Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions tests/api/test_flexible_calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_dir_with_space(self):
with self.assertLogs() as logobs:
json_case_path = "./tests/api/data/flexible_calling_unit_test/verification_case_unit_test_Path.json"

# Change working_dir value in the json file to a valid path
# Change working_dir value in the json file to a valid path in Linux format with space
with open(json_case_path, "r") as f:
workflow_dict = json.load(f)
workflow_dict["working_dir"] = "./tests/api/result/dir space"
Expand All @@ -170,7 +170,7 @@ def test_dir_with_space(self):
)

with self.assertLogs() as logobs:
# Change working_dir value in the json file to a valid path in Win format
# Change working_dir value in the json file to a valid path in Win format with space
with open(json_case_path, "r") as f:
workflow_dict = json.load(f)
workflow_dict["working_dir"] = ".\\tests\\api\\result\\dir space"
Expand Down Expand Up @@ -282,13 +282,37 @@ def test_dir_not_exist(self):
# print(os.getcwd())

# But I always get error deleting this directory:
# os.remove("./tests/api/result/not_existing_path/test")
# os.remove("./tests/api/result/not_existing_path")

self.assertEqual(
logobs.output[1],
"INFO:root:working directory specified does not exist and create a new director.",
)

def test_dir_without_seperator(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added a unit test for working directories without any "/" or "\"

"""This test checks when a working directory without any "/" or "\\" is provided and it also points to the correct path,
if the program will behave correctly"""
with self.assertLogs() as logobs:
json_case_path = "./tests/api/data/flexible_calling_unit_test/verification_case_unit_test_Path.json"

# Change working_dir value in the json file to a valid path
with open(json_case_path, "r") as f:
workflow_dict = json.load(f)
workflow_dict["working_dir"] = "tests"

with open(json_case_path, "w") as f:
json.dump(workflow_dict, f)

workflow = Workflow(workflow=json_case_path)

# change current working directory back
os.chdir("../")

self.assertEqual(
logobs.output[0],
"INFO:root:Change current working path to the specified path.",
)


if __name__ == "__main__":
unittest.main()
Loading