Skip to content

Commit

Permalink
Update test_analysis.py
Browse files Browse the repository at this point in the history
added a unittest
  • Loading branch information
eletoups authored Jun 6, 2024
1 parent f802d0c commit 25ec302
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion alfred/tests/test_analysis.py
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()

0 comments on commit 25ec302

Please sign in to comment.