forked from NCSU-SE-2024/PackReview_v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import unittest | ||
from unittest.mock import patch, MagicMock | ||
from flask import session, jsonify | ||
from app import app | ||
from pymongo.errors import PyMongoError | ||
|
||
class TestGetUser(unittest.TestCase): | ||
def setUp(self): | ||
"""Set up test client.""" | ||
self.app = app.test_client() | ||
self.app.testing = True | ||
|
||
def test_get_user_with_username(self): | ||
"""Test retrieving the username from the session when available.""" | ||
with self.app.session_transaction() as sess: | ||
sess['username'] = 'testuser' | ||
|
||
response = self.app.get('/api/getUser') | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.get_json(), 'testuser') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |