Skip to content

Commit

Permalink
Update test_app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KKGanguly authored Nov 27, 2024
1 parent d8598e0 commit 094038e
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def test_upvote_review(self):
response = self.client.get(f'/upvote/{job_id}')
self.assertEqual(response.status_code, 302)

def test_pagination(self):
"""Test pagination on pageContent."""
response = self.client.get('/pageContent?page=1&per_page=10')
self.assertEqual(response.status_code, 200)

def test_delete_review(self):
"""Test deleting a job review."""
Expand Down Expand Up @@ -307,6 +311,11 @@ def test_delete_nonexistent_review(self):
# with self.assertRaises(ValueError):
# self.client.get(f'/delete/{job_id}')

def test_pagination_bounds(self):
"""Test pagination with a page number that exceeds available pages."""
response = self.client.get('/pageContent?page=999&per_page=10')
# Assuming you handle this case
self.assertEqual(response.status_code, 200)

def test_edit_review(self):
"""Test editing a job review."""
Expand Down Expand Up @@ -453,7 +462,35 @@ def test_index_route(self):
response = self.client.get('/')
assert response.status_code == 200

def test_page_content_route(self):
"""
Test the page content route with a POST request to verify successful
response (status code 200) for valid data.
"""
response = self.client.post(
'/pageContentPost',
data={
"search": "Setup"})
assert response.status_code == 200

def test_add_post_route(self):
"""
Test the add post route with a POST request to ensure the submission
of a new job post is successful (status code 200).
"""
response = self.client.post('/pageContentPost', data={
"job_title": "1",
"job_description": "2",
"department": "3",
"locations": "4",
"hourly_pay": "5",
"benefits": "6",
"review": "7",
"rating": "2",
"recommendation": "2",
"search": ""
})
assert response.status_code == 200

def test_signup_route(self):
"""Test the signup route for successful access (status code 200)."""
Expand All @@ -473,13 +510,34 @@ def test_add_review_route(self):
response = self.client.get('/review')
assert response.status_code == 302

def test_review_route(self):
"""Test the review route for successful access (status code 200)."""
response = self.client.get('/pageContent')
assert response.status_code == 200

def test_filter_jobs_route(self):
"""Test filtering jobs by department and company."""
response = self.client.post('/pageContentPost', data={
"search": "Engineer",
"dept_filter": "Engineering",
"company_filter": "TechCorp"
})
assert response.status_code == 200

def test_view_forum_topic_route(self):
"""Test viewing a specific forum topic."""
topic_id = '672531d244fdeb1ec36c110d'
response = self.client.get(f'/forum/{topic_id}')
assert response.status_code == 200

def test_my_jobs_route(self):
"""Test viewing my jobs."""
with self.client as client:
with client.session_transaction() as session:
session['username'] = 'existinguser' # Mock the session login

response = client.get('/myjobs')
assert response.status_code == 200

def test_get_user_logged_in(self):
"""Test for logging in users."""
Expand Down

0 comments on commit 094038e

Please sign in to comment.