-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved user db stuff to file_manager (#2046)
- Loading branch information
1 parent
3be1bdc
commit afc9e27
Showing
3 changed files
with
72 additions
and
13 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 |
---|---|---|
|
@@ -26,10 +26,11 @@ | |
""" | ||
from flask_testing import TestCase | ||
import os | ||
import datetime | ||
import pytest | ||
|
||
from mslib.mscolab.conf import mscolab_settings | ||
from mslib.mscolab.models import Operation | ||
from mslib.mscolab.models import Operation, User | ||
from mslib.mscolab.server import APP | ||
from mslib.mscolab.file_manager import FileManager | ||
from mslib.mscolab.seed import add_user, get_user | ||
|
@@ -80,6 +81,40 @@ def setUp(self): | |
def tearDown(self): | ||
pass | ||
|
||
def test_modify_user(self): | ||
with self.app.test_client(): | ||
user = User("[email protected]", "user", "password") | ||
assert user.id is None | ||
assert User.query.filter_by(emailid=user.emailid).first() is None | ||
# creeat the user | ||
self.fm.modify_user(user, action="create") | ||
user_query = User.query.filter_by(emailid=user.emailid).first() | ||
assert user_query.id is not None | ||
assert user_query is not None | ||
assert user_query.confirmed is False | ||
# cannot create a user a second time | ||
assert self.fm.modify_user(user, action="create") is False | ||
# confirming the user | ||
confirm_time = datetime.datetime.now() + datetime.timedelta(days=1) | ||
self.fm.modify_user(user_query, attribute="confirmed_on", value=confirm_time) | ||
self.fm.modify_user(user_query, attribute="confirmed", value=True) | ||
user_query = User.query.filter_by(id=user.id).first() | ||
assert user_query.confirmed is True | ||
assert user_query.confirmed_on == confirm_time | ||
assert user_query.confirmed_on > user_query.registered_on | ||
# deleting the user | ||
self.fm.modify_user(user_query, action="delete") | ||
user_query = User.query.filter_by(id=user_query.id).first() | ||
assert user_query is None | ||
|
||
def test_modify_user_special_cases(self): | ||
user1 = User("[email protected]", "user1", "password") | ||
user2 = User("[email protected]", "user2", "password") | ||
self.fm.modify_user(user1, action="create") | ||
self.fm.modify_user(user2, action="create") | ||
user_query1 = User.query.filter_by(emailid=user1.emailid).first() | ||
assert self.fm.modify_user(user_query1, "emailid", user2.emailid) is False | ||
|
||
def test_fetch_operation_creator(self): | ||
with self.app.test_client(): | ||
flight_path, operation = self._create_operation(flight_path="more_than_one") | ||
|