-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor secret key and database configuration to use environment var…
…iables; enhance user creation tests.
- Loading branch information
Showing
5 changed files
with
29 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
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
Binary file modified
BIN
+1.63 KB
(130%)
tests/test_web_interface/__pycache__/user_data_test.cpython-312-pytest-8.2.2.pyc
Binary file not shown.
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 |
---|---|---|
@@ -1,23 +1,37 @@ | ||
import pytest | ||
from web_interface.user_data import VonUser | ||
import os | ||
|
||
test_user={'username':'testuser', 'email':'[email protected]', 'password':'testpassword'} | ||
|
||
def test_set_userDB(): | ||
VonUser.set_userDB('testDB', 'testCollection') | ||
assert VonUser.userdb.name == 'testDB' | ||
assert VonUser.usercollection.name == 'testCollection' | ||
|
||
def test_create_user(): | ||
VonUser.set_userDB('testDB', 'testCollection') | ||
user = VonUser.create_user(test_user['username'], test_user['email'], test_user['password']) | ||
|
||
def test_init_user(): | ||
user = VonUser('zhan') | ||
assert user.get_username() == 'zhan' | ||
assert user.email == '[email protected]' | ||
assert user.id is not None | ||
VonUser.set_userDB('testDB', 'testCollection') | ||
user = VonUser.create_user(test_user['username'], test_user['email'], test_user['password']) | ||
|
||
user = VonUser(test_user['username']) | ||
assert user.get_username() == test_user['username'] | ||
assert user.email == test_user['email'] | ||
assert user.password == test_user['password'] | ||
assert user.id is not None | ||
|
||
def test_database_structure(): | ||
dbname=os.getenv('VON_CONFIG_DB') | ||
collname=os.getenv('VON_USER_COLLECTION') | ||
|
||
VonUser.set_userDB() # use default values | ||
db=VonUser.get_userDB() | ||
assert db.name == 'vonUsers' | ||
assert db.name == dbname | ||
coll=VonUser.get_userCollection() | ||
assert coll.name == 'users' | ||
assert coll.name == collname | ||
|
||
# def test_update_email(mock_user_collection): | ||
# VonUser.usercollection = mock_user_collection | ||
|