Skip to content

Commit

Permalink
modified tests to import pdf's directly from PDF directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-holdener committed Nov 29, 2024
1 parent b44daea commit f281fa3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ServerCode/BubbleScan_AI/tests/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_correct_alignment(self):
cv2.circle(template, (500, 500), 50, (255, 255, 255), -1) # Circle in the template

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Align the image with the template
aligned = scantron.align_image(image, template)
Expand All @@ -31,7 +31,7 @@ def test_missing_keypoints(self):
template = np.zeros((1000, 1000, 3), dtype=np.uint8)

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Attempt to align the image with the template
aligned = scantron.align_image(image, template)
Expand Down
8 changes: 4 additions & 4 deletions ServerCode/BubbleScan_AI/tests/test_bubble_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_get_responses_bubble_row_single_fill(self):
cv2.circle(image, (x_center, 50), 30, (0, 0, 0), -1) # Black filled circle

# Instantiate the TestScantron95945 class
scantron = Scantron95945TestHelper('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945TestHelper('PDF/Scans-4-2-24.pdf')

# Get the response from the image
response = scantron.get_responses_bubble_row(image)
Expand All @@ -37,7 +37,7 @@ def test_get_responses_bubble_row_multiple_fills(self):
cv2.circle(image, (x_center_B, 50), 30, (0, 0, 0), -1) # Black filled circle for 'B'

# Instantiate the TestScantron95945 class
scantron = Scantron95945TestHelper('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945TestHelper('PDF/Scans-4-2-24.pdf')

# Get the response from the image
response = scantron.get_responses_bubble_row(image)
Expand All @@ -54,7 +54,7 @@ def test_bubble_column_single_fill(self):
cv2.rectangle(column, (0, 400), (100, 500), 255, -1) # Filling bubble at index 4

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Get the index of the filled bubble
index = scantron.bubble_column(column)
Expand All @@ -69,7 +69,7 @@ def test_bubble_column_no_fill(self):
column = np.zeros((1000, 100, 1), dtype=np.uint8)

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Get the index of the filled bubble
index = scantron.bubble_column(column)
Expand Down
4 changes: 2 additions & 2 deletions ServerCode/BubbleScan_AI/tests/test_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from BubbleScan_AI.Scantron import Scantron95945

class TestErrorHandling:
"""Test how the system handles a corrupted PDF file."""
"""Test how the system handles a corrupted `PDF file."""
@patch('fitz.open')
def test_corrupted_pdf_handling(self, mock_fitz_open):
"""Test how the system handles a corrupted PDF file."""
Expand All @@ -20,7 +20,7 @@ def test_missing_image_files(self):
"""Test how the system handles missing image files during template matching."""

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Mock os.listdir to return an empty list (no image files)
with patch('os.listdir', return_value=[]):
Expand Down
4 changes: 2 additions & 2 deletions ServerCode/BubbleScan_AI/tests/test_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_complete_student_id(self):
roi_color = cv2.cvtColor(roi, cv2.COLOR_GRAY2BGR)

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Extract the student ID
student_id = scantron.student_id(roi_color)
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_incomplete_student_id(self):
roi_color = cv2.cvtColor(roi, cv2.COLOR_GRAY2BGR)

# Instantiate the Scantron95945 class
scantron = Scantron95945('BubbleScan_AI/PDF/Scans-4-2-24.pdf')
scantron = Scantron95945('PDF/Scans-4-2-24.pdf')

# Extract the student ID
student_id = scantron.student_id(roi_color)
Expand Down

0 comments on commit f281fa3

Please sign in to comment.