-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a unittest
- Loading branch information
Showing
1 changed file
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,44 @@ | ||
import alfred | ||
import altair as alt | ||
import csv | ||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
import pathlib | ||
import re | ||
import shutil | ||
import numpy as np | ||
import os | ||
from io import StringIO | ||
from os import listdir | ||
from sklearn.decomposition import PCA | ||
|
||
# tests on alfred.analysis | ||
data_path = os.path.join(alfred.__path__[0], 'data/sorted_test_data') | ||
|
||
class TestCountSwappedModules(unittest.TestCase): | ||
def setUp(self): | ||
self.valid_directory = os.path.join(data_path, 'all_buses/') | ||
|
||
def test_count_swapped_modules_output(self): | ||
# Capture the output of the function | ||
captured_output = StringIO() | ||
sys.stdout = captured_output | ||
|
||
# Call the function | ||
output = alfred.count_swapped_modules(self.valid_directory) | ||
|
||
# Restore stdout | ||
sys.stdout = sys.__stdout__ | ||
|
||
# Get the captured output | ||
captured_output_str = captured_output.getvalue() | ||
|
||
# Check if the key elements are in the captured output | ||
self.assertIn("COUNT OF SWAPPED MODULES", captured_output_str) | ||
self.assertIn("Count of '0':", captured_output_str) | ||
self.assertIn("Count of '1':", captured_output_str) | ||
self.assertIn("0 = healthy and 1 = swapped", captured_output_str) | ||
def tearDown(self): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |