Skip to content

Commit

Permalink
Merge pull request #78 from COS301-SE-2024/test/backendEntry
Browse files Browse the repository at this point in the history
checking
  • Loading branch information
Yudi-G authored Jun 24, 2024
2 parents cccb169 + 73971d1 commit 9e40f9a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ bin/
obj/
**/__pycache__/
venv/

myenv/

Binary file modified backend/__pycache__/backend_entry.cpython-312.pyc
Binary file not shown.
61 changes: 61 additions & 0 deletions backend/backend_entry_int_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import unittest
from backend_entry import backend_entry

class TestBackendEntryIntegration(unittest.TestCase):

def test_process_returns_expected_output(self):
# Arrange
path = './mockdata/NCE1.pdf'
expected_output = (
"Most probable countries of origin:\n"
"Predominant Language of Country of Origin: English,\n"
"\n"
"Violation Report:\n"
"Category: General Personal Data\n"
"Total per category: 56\n"
"\n"
"Category: Genetic Data\n"
"Total per category: 0\n"
"\n"
"Category: Biometric Data\n"
"Total per category: 0\n"
"\n"
"Category: Data relating to Health\n"
"Total per category: 0\n"
"\n"
"Category: Data revealing Racial and Ethnic Origin\n"
"Total per category: 0\n"
"\n"
"Category: Political Opinions\n"
"Total per category: 0\n"
"\n"
"Category: Religious or Ideological Convictions\n"
"Total per category: 0\n"
"\n"
"Category: Occupational Information\n"
"Total per category: 2\n"
"\n"
)

# Act
result = backend_entry.process(path)

# Remove the 'Probability' line from the actual result
actual_output_lines = result.splitlines()
filtered_actual_output_lines = [
line for line in actual_output_lines if not line.startswith("Probability:")
]
filtered_actual_output = "\n".join(filtered_actual_output_lines).strip() # Normalize newlines and strip whitespace

# Debugging output
print("Expected Output:")
print(expected_output)
print("\nFiltered Actual Output:")
print(filtered_actual_output)

# Assert
for line in expected_output.splitlines():
self.assertIn(line.strip(), filtered_actual_output)

if __name__ == '__main__':
unittest.main()

0 comments on commit 9e40f9a

Please sign in to comment.