Example #1
0
import requester as r
import time
from requester import test_print

r.verify = False

r.initialize_and_clear_tables()

admin_session = r.session

desc = '#### update admin user to have new email ####'
res = r.update_user(username="******",email_address="*****@*****.**")
test_print(desc, res.status_code < 300)

desc = '#### create API token ####'
res = r.get_api_token()
test_print(desc, res.status_code < 300)
token = r.json.loads(res.content)['results']['token']
test_print(desc, token != None)

#r.headers['Auth-Token'] = token

desc = '#### get current user ####'
res = r.get_user()
test_print(desc, r.json.loads(res.content)['results']['username'] == 'admin')

desc = '#### get all users in DB, make sure theres only 1 and that the username == admin ####'
res = r.get_all_users()
test_print(desc, len(r.json.loads(res.content)['results']) == 1)
test_print(desc, r.json.loads(res.content)['results'][0]['email_address'] == '*****@*****.**')
Example #2
0
def test_print(desc, expression):
	global failed, passed
	if not expression:
		print desc
		print expression
		failed += 1
	else:
		passed += 1

desc = '#### initialize session ####'
session_response = r.login_to_session('admin', 'Treeadmin')
test_print(desc, session_response.status_code < 300)
r.session = session_response.cookies

dec = '#### update admin user to have new email ####'
res = r.update_user(username="******",email_address="*****@*****.**")
test_print(desc, res.status_code < 300)

desc = '#### create API token ####'
res = r.get_api_token()
test_print(desc, res.status_code < 300)
token = r.json.loads(res.content)['results']['token']
test_print(desc, token != None)
r.headers['Auth-Token'] = token

desc = '#### get current user ####'
res = r.get_user()
test_print(desc, r.json.loads(res.content)['results']['username'] == 'admin')

desc = '#### get all users in DB, make sure theres only 1 and that the username == admin ####'
res = r.get_all_users()