예제 #1
0
def generate_users(n):
    users = list()
    for i in range(n):
        user = User(faker.name())
        user.username = faker.name()
        user.password = "******"
        try:
            db.session.add(user)
            db.session.commit()
            users.append(user)
        except Exception as e:
            log.error("Fail to add user %s: %s" % (str(user), e))
            db.session.rollback()
    return users
예제 #2
0
파일: demo.py 프로젝트: djour/pythonObjects
def main():

    user = User('John', 'password', '*****@*****.**', '12/25/1999')
    print(user.username)
    print(user.password)
    print(user)
    print()
    print(repr(user))

    user2 = User("John", "password", "*****@*****.**", "12/25/1999")
    print(user == user2)
    print(user.check_password('1234'))

    user.username = '******'
    print(user.username)

    superuser = SuperUser('jon', 'password', '*****@*****.**', '12/24/1999',
                          'admin')

    print(superuser)
    print()
    print(repr(superuser))

    print('ran demo.main')
예제 #3
0
#!/usr/bin/python

import os, sys
import hashlib

sys.path.insert(1, os.path.join(sys.path[0], '../src'))

from main import db, User

items = ['NumerousDiamond', 'AcceptableVillage', 'InformalEditor', 'ImportantRoad', 'HistoricalPainting', 'SexualClimate', 'ConsistentConcept', 'DesperateCoffee', 'ScaredFood', 'OddCurrency', 'AsleepImportance', 'GuiltyManager', 'ScaredGrandmother', 'PoliticalChapter', 'UnusualEmphasis', 'DramaticArt', 'InnerHealth', 'SevereAssociation', 'NiceInternet', 'ElectronicAffair', 'MedicalFeedback', 'ElectricalArrival', 'LatterExplanation', 'SufficientApartment', 'CulturalPeople', 'DistinctGirl', 'DangerousIdea', 'SeriousMeaning', 'SuitableCity', 'HotApplication', 'EasternActivity', 'SeveralGrandmother', 'KnownInsurance', 'EducationalOven', 'IntelligentBeer', 'PoorMoment', 'AdministrativeManagement', 'StrictContext', 'EfficientCandidate', 'MentalTale']

for item in items:
  u = User()
  u.username = item
  u.email = item.lower()+'@pnyx.app'
  u.password = hashlib.sha384(os.urandom(24)).hexdigest()
  u.save()
예제 #4
0
def test_generates_valid_token():
    user = User()
    user.id = 1
    user.username = "******"
    assert user.generate_auth_token()
예제 #5
0
def test_throws_exception_when_generating_token_without_id():
    user = User()
    user.username = "******"
    with pytest.raises(Exception):
        token = user.generate_auth_token()