Skip to content

Commit

Permalink
add capability to recursively check if paths are file/directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelbaker-cisa committed Jul 6, 2024
1 parent 5f0a90d commit a6640f8
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions Testing/Functional/SmokeTests/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,57 @@ def test_cli(self, subjectemail):

directories = [d for d in os.listdir() if os.path.isdir(d) and d.startswith(prefix)]
directories.sort(key=lambda d: os.path.getctime(d), reverse=True)
print(directories)
print(directories[0])

output_path = os.path.join(cwd, directories[0])
individual_reports_path = f"{output_path}/IndividualReports"
print(individual_reports_path)

def check_output_contents(output_path):
try:
entries = os.listdir(output_path)
print(entries)
for entry in entries:
child_path = os.path.join(output_path, entry)

# Directory case
if os.path.isdir(child_path):
assert os.path.isdir(child_path)
check_output_contents(child_path)

# File case
elif os.path.isfile(child_path):
assert os.path.isfile(child_path)

# Neither a directory or file (symlink, etc.)
else:
assert False
except FileNotFoundError:
assert False, f"The directory {output_path} does not exist"
except Exception as e:
assert False, f"An error occurred, {e}"

check_output_contents(output_path)

#assert "BaselineReports.html" in entries and os.path.isfile(f"{output_path}/BaselineReports.html")
#assert "IndividualReports" in entries and os.path.isdir(individual_reports_path)
#assert "ProviderSettingsExport.json" in entries and os.path.isfile(f"{output_path}/ProviderSettingsExport.json")
#assert "TestResults.json" in entries and os.path.isfile(f"{output_path}/TestResults.json")
#
#assert "CalendarReport.html" in os.listdir(individual_reports_path)
#assert "ChatReport.html" in os.listdir(individual_reports_path)
#assert "ClassroomReport.html" in os.listdir(individual_reports_path)
#assert "CommoncontrolsReport.html" in os.listdir(individual_reports_path)
#assert "DriveReport.html" in os.listdir(individual_reports_path)
#assert "GmailReport.html" in os.listdir(individual_reports_path)
#assert "GroupsReport.html" in os.listdir(individual_reports_path)
#assert "MeetReport.html" in os.listdir(individual_reports_path)
#assert "RulesReport.html" in os.listdir(individual_reports_path)
#assert "SitesReport.html" in os.listdir(individual_reports_path)







#def create_venv(env):
Expand Down

0 comments on commit a6640f8

Please sign in to comment.