def add_user2(): with app.app_context(): user = User() user.email = email2 user.password = password2 user.level = UserLevel.DEFAULT user.insert() return user
def add_user4(): with app.app_context(): user = User() user.email = email4 user.password = '******' user.activation_token = activation_token user.level = UserLevel.REGISTERED user.insert() return user
def new_user(password, save=True): address = unittest_address(str(uuid4())) user = User() user.email = address user.password = password user.level = UserLevel.DEFAULT if save: user.insert() return address
def add_user3(): with app.app_context(): user = User() user.email = email3 user.password = password3 user.level = UserLevel.ADMIN character = Character() character.eve_id = character_id3 character.name = character_name3 character.token = json.dumps({ 'access_token': 'foo', 'expires_at': time.time() - 600, # Expired 10 minutes ago 'refresh_token': 'bar' }) user.characters = [character] user.insert() return user
def test_insert_user_with_character(self): u = User() u.email = EMAIL2 u.password = PASSWORD2 u.level = 321 u.activation_token = 'a-token for user 2' c1 = Character() c1.eve_id = 1 c1.token = 'token #1' c2 = Character() c2.eve_id = 2 c2.token = 'token #2' u.characters = [c1, c2] self.assertIsNotNone(u.insert()) u2 = user_loader(EMAIL2) self.assertTrue(isinstance(u2, User))
def setUp(self): warnings.filterwarnings('ignore', message='unclosed <ssl\.SSLSocket ', category=ResourceWarning) warnings.filterwarnings( 'ignore', message='The psycopg2 wheel package will be renamed ', category=UserWarning) warnings.filterwarnings('ignore', message='update is deprecated.', category=DeprecationWarning) warnings.filterwarnings('ignore', message='save is deprecated.', category=DeprecationWarning) warnings.filterwarnings('ignore', message='remove is deprecated.', category=DeprecationWarning) app.config.from_object('bootini_star.config.Testing') self.app = app.test_client() with app.app_context(): user = User(ensure_indexes=True) user.email = email user.password = password user.level = UserLevel.DEFAULT character = Character() character.eve_id = character_id character.name = character_name character.token = { 'access_token': 'foo', 'expires_at': time.time() + 600, # Expires in 10 minutes 'refresh_token': 'bar' } user.characters = [character] self.assertIsNotNone(user.insert())
def test_insert_valid_user(self): u = User() u.email = EMAIL2 u.password = PASSWORD2 self.assertIsNotNone(u.insert())
def test_insert_duplicate_user(self): u = User() u.email = EMAIL u.password = '******' + PASSWORD with self.assertRaises(pymongo.errors.DuplicateKeyError): u.insert()
def setUp(self): u = User(ensure_indexes=True) u.email = EMAIL u.password = PASSWORD mongo_id = u.insert() self.assertIsNotNone(mongo_id)