예제 #1
0
def populate_db(br=None, size=MAX_USERS):
    if not br:
        br = init_browser()        
    print ''
    
    for index in range(size):    
        sys.stdout.write('\rPopulating the database with {} new users over {}'.format(index+1, MAX_USERS))
        sys.stdout.flush()
        add_user(br)
    DBSession.commit()
    print ''    
예제 #2
0
def populate_db(br=None, size=MAX_USERS):
    if not br:
        br = init_browser()
    print ''

    for index in range(size):
        sys.stdout.write(
            '\rPopulating the database with {} new users over {}'.format(
                index + 1, MAX_USERS))
        sys.stdout.flush()
        add_user(br)
    DBSession.commit()
    print ''
예제 #3
0
    def __init__(self, browser):
        rand = random.randrange(0, MAX_USERS) 
        row = DBSession.query(User.id, User.username, User.password)[rand]
            
        self.id = row.id
        self.username = row.username
        self.password = row.password

        self.br = browser
        self.logged_in = False
예제 #4
0
    def __init__(self, browser):
        rand = random.randrange(0, MAX_USERS)
        row = DBSession.query(User.id, User.username, User.password)[rand]

        self.id = row.id
        self.username = row.username
        self.password = row.password

        self.br = browser
        self.logged_in = False
예제 #5
0
def add_user(br):
    timer=()
    # build a brand new fake user
    random_uid = str(uuid.uuid4())
    
    fullname = random_uid
    username = BASE_USERNAME+random_uid[:8]
    password = random_uid[:8]

    _ = br.open(BASE_URL+'/join')

    br.select_form(nr=0)
    br.form[ 'fullname' ] = fullname
    br.form[ 'username' ] = username
    br.form[ 'password' ] = password
    br.form[ 'confirm' ] = password
    br.form[ 'about' ] = ABOUT

    start_time = time.time()
    resp = br.submit()
    resp.read()
    latency = time.time() - start_time
    # verify responses are valid
    assert (resp.code == 200), 'Bad Response: HTTP %s' % resp.code
    
    if resp.geturl() == BASE_URL+'/join':
        timer = 'Failed_registration', latency
    else:
        timer = 'Register_new_user', latency
        # add user in the local db (for future retrieval)
        DBSession.add( User (username=username, password=password) )
        
        # logout and reset cookie
        resp = br.open(BASE_URL+'/logout')
#        resp.read()
        # verify responses are valid
        assert (resp.code == 200), 'Bad Response: HTTP %s' % resp.code
        assert ('Public Timeline' in resp.get_data()), 'Text Assertion Failed'  
        
    return timer
예제 #6
0
def add_user(br):
    timer = ()
    # build a brand new fake user
    random_uid = str(uuid.uuid4())

    fullname = random_uid
    username = BASE_USERNAME + random_uid[:8]
    password = random_uid[:8]

    _ = br.open(BASE_URL + '/join')

    br.select_form(nr=0)
    br.form['fullname'] = fullname
    br.form['username'] = username
    br.form['password'] = password
    br.form['confirm'] = password
    br.form['about'] = ABOUT

    start_time = time.time()
    resp = br.submit()
    resp.read()
    latency = time.time() - start_time
    # verify responses are valid
    assert (resp.code == 200), 'Bad Response: HTTP %s' % resp.code

    if resp.geturl() == BASE_URL + '/join':
        timer = 'Failed_registration', latency
    else:
        timer = 'Register_new_user', latency
        # add user in the local db (for future retrieval)
        DBSession.add(User(username=username, password=password))

        # logout and reset cookie
        resp = br.open(BASE_URL + '/logout')
        #        resp.read()
        # verify responses are valid
        assert (resp.code == 200), 'Bad Response: HTTP %s' % resp.code
        assert ('Public Timeline' in resp.get_data()), 'Text Assertion Failed'

    return timer