Skip to content

Commit

Permalink
Teardown added
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrimadh committed Nov 1, 2024
1 parent 05997ec commit 4064ea9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on: [push]

jobs:
upload-coverage:
unittest:
runs-on: ubuntu-latest
env:
MONGO_URI: ${{ secrets.MONGO_URI }}
Expand All @@ -28,4 +28,4 @@ jobs:
echo "MONGO_URI=${{ secrets.MONGO_URI }}" >> .env
- name: Test with pytest
run: pytest --tb=line
run: pytest -v
35 changes: 35 additions & 0 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ def tearDownClass(cls):
class TestUtilityFunctions(BaseTestCase):
"""Test class for utility functions like tags, data formatting, etc."""

@classmethod
def tearDownClass(cls):
"""Clean up after all tests in this class"""
cls.db.users.delete_many({})
cls.db.movies.delete_many({})
cls.db.ratings.delete_many({})

def test_create_colored_tags(self):
"""Test generating HTML tags with specific colors for movie genres."""
genres = ["Musical", "Sci-Fi"]
Expand Down Expand Up @@ -132,6 +139,13 @@ def test_create_movie_genres(self):
class TestEmailFunctionality(BaseTestCase):
"""Test class for email-related functionality"""

@classmethod
def tearDownClass(cls):
"""Clean up after all tests in this class"""
cls.db.users.delete_many({})
cls.db.movies.delete_many({})
cls.db.ratings.delete_many({})

@patch("smtplib.SMTP")
def test_send_email_to_user(self, mock_smtp):
"""Test sending email to user with categorized movie feedback."""
Expand Down Expand Up @@ -174,6 +188,13 @@ def test_send_email_smtp_error(self, mock_smtp):
class TestUserManagement(BaseTestCase):
"""Test class for user management functionality"""

@classmethod
def tearDownClass(cls):
"""Clean up after all tests in this class"""
cls.db.users.delete_many({})
cls.db.movies.delete_many({})
cls.db.ratings.delete_many({})

def test_create_account(self):
"""Test creating a new user account."""
result = create_account(
Expand Down Expand Up @@ -227,6 +248,13 @@ def test_add_friend_and_get_friends(self):
class TestReviewAndRating(BaseTestCase):
"""Test class for review and rating functionality"""

@classmethod
def tearDownClass(cls):
"""Clean up after all tests in this class"""
cls.db.users.delete_many({})
cls.db.movies.delete_many({})
cls.db.ratings.delete_many({})

def test_submit_review(self):
"""Test submitting movie reviews."""
user_id = login_to_account(
Expand Down Expand Up @@ -286,6 +314,13 @@ def test_get_user_history_invalid_id(self):
class TestMovieFeatures(BaseTestCase):
"""Test class for movie-related features"""

@classmethod
def tearDownClass(cls):
"""Clean up after all tests in this class"""
cls.db.users.delete_many({})
cls.db.movies.delete_many({})
cls.db.ratings.delete_many({})

def test_get_recent_movies(self):
"""Test retrieving recent movies."""
user_id = login_to_account(
Expand Down

0 comments on commit 4064ea9

Please sign in to comment.