Skip to content

Commit

Permalink
Merge pull request #1 from FNNDSC/vsm/directory-tree
Browse files Browse the repository at this point in the history
Vsm/directory tree
  • Loading branch information
matthewhu8 authored Aug 9, 2024
2 parents b3ced43 + 31fb8e5 commit c6978db
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Empty file.
1 change: 1 addition & 0 deletions .github/workflows/test_code demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def test_code_demo()
24 changes: 23 additions & 1 deletion mdharvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
start_date = options.startdate
end_date = options.enddate
print(DISPLAY_TITLE)
dateTreeBuild(start_date, end_date, outputdir)
test_dateTreeBuild()

def dateTreeBuild(start_date, end_date, outputdir):
#Create Datetime objects

start_date = ''.join(filter(str.isdigit, start_date))
end_date = ''.join(filter(str.isdigit, end_date))

try:
start = datetime.strptime(start_date, '%Y%m%d')
end = datetime.strptime(end_date, '%Y%m%d')
Expand All @@ -86,7 +90,25 @@ def dateTreeBuild(start_date, end_date, outputdir):
os.makedirs(directory_path, exist_ok = True)

current_date += timedelta(days = 1)
def test_dateTreeBuild():

print("Test1: Valid Date Range")
dateTreeBuild('20230101', '20230105', 'test_dir1')

print("\nTest 2: End Date Before Start Date")
dateTreeBuild('20220105', '20220101', 'test_dir2')

print("\nTest 3:Invalid Date Format")
try:
dateTreeBuild('2022-01-01', '20220105', 'test_dir3')
except SystemExit as e:
print("Caught an expected SystemExit due to invalid date format")



print("\nTest 4: Same Start and End Date")
dateTreeBuild('20220101', '20220101', 'test_dir4')


if __name__ == '__main__':
main()

0 comments on commit c6978db

Please sign in to comment.