def test_cm(self): cookie = test_login.login() common_url = conf.ReadConfig().getloginConfigValue('url') jsondatas = ['data'] for i in range(int(get.get_nrows('cm')) - 1): #读取jsonpath jsonpathexcel = get.get_jsonpath('cm', i + 1) # 判断是否执行 if int(get.get_data('cm', i + 1, 4)) == 1: login_url = get.get_data('cm', i + 1, 2) url = common_url + login_url data = get.get_formdata('cm', i + 1, jsondatas[-1]) header = { "Content-Type": "application/x-www-form-urlencoded", "Cookie": cookie } global r print url if get.get_data('cm', i + 1, 3) == 'post': r = requests.post(url=url, headers=header, data=data) time_consume = r.elapsed.microseconds if checkall.checkall('cm', i + 1, r.status_code, r.content) == 'pass': set.set_result(2, i + 1, 'pass') elif checkall.checkall('cm', i + 1, r.status_code, r.content) == 'fail': set.set_result(2, i + 1, 'fail') if jsonpathexcel != '': jsondata = getjson.get_rcontent( json.loads(r.content), jsonpathexcel) jsondatas.append(jsondata) set.set_statuscode(2, i + 1, r.status_code) set.set_content(2, i + 1, r.content.decode('UTF-8')) set.set_sql(2, i + 1, checkdb.check('cm', i + 1)[1]) elif get.get_data('cm', i + 1, 3) == 'get': r = requests.get(url=url, headers=header, data=data) if checkall.checkall('cm', i + 1, r.status_code, r.content) == 'pass': set.set_result(2, i + 1, 'pass') elif checkall.checkall('cm', i + 1, r.status_code, r.content) == 'fail': set.set_result(2, i + 1, 'fail') if jsonpathexcel != '': jsondata = getjson.get_rcontent( json.loads(r.content), jsonpathexcel) jsondatas.append(jsondata) set.set_statuscode(2, i + 1, r.status_code) set.set_content(2, i + 1, r.content.decode('UTF-8')) set.set_sql(2, i + 1, checkdb.check('cm', i + 1)[1]) set.set_time(2, i + 1, str(time_consume)) elif int(get.get_data('cm', i + 1, 4)) == 0: print 'not execute' set.set_result(2, i + 1, 'not execute')
def test_shadow_invalid(client, god_user): """Shadowing an invalid user id simply makes you not shadowing.""" god = god_user() assert b'You were logged in' in login(client, god.nickname, "").data response = shadow_user(client, -1) assert response.status_code == 200 assert 'shadow_user' not in session
def test_shadow_replace(client, god_user, test_user): """Shadowing a user when already shadowing should work the same as unshadowing and reshadowing.""" god = god_user() test1 = test_user() assert b'You were logged in' in login(client, god.nickname, "").data assert shadow_user(client, test1.id).status_code == 200 test2 = test_user() response = shadow_user(client, test2.id) assert response.status_code == 200 assert session['current_user'] == test2.id assert session['shadow_user'] != test1.id assert session['shadow_user'] == god.id assert get_logged_in() == test2
def test_shadow_valid(client, god_user, test_user): """Shadowing a user makes them the current_user and you the shadow_user.""" god = god_user() test = test_user() assert b'You were logged in' in login(client, god.nickname, "").data response = shadow_user(client, test.id) assert response.status_code == 200 assert session['current_user'] == test.id assert session['shadow_user'] == god.id assert get_logged_in() == test # after shadowing, you should also be able to unshadow base_test.check_response(shadow_user(client, None)) assert session['current_user'] == god.id assert 'shadow_user' not in session or session['shadow_user'] is None assert get_logged_in() == god
def test_pd(self): cookie = test_login.login() common_url = conf.ReadConfig().getloginConfigValue('url') for i in range(int(get.get_nrows('pd')) - 1): # 判断是否执行 if int(get.get_data('pd', i + 1, 4)) == 1: login_url = get.get_data('pd', i + 1, 2) url = common_url + login_url data = get.get_formdata('pd', i + 1) header = { "Content-Type": "application/x-www-form-urlencoded", "Cookie": cookie } global r print url if get.get_data('pd', i + 1, 3) == 'post': r = requests.post(url=url, headers=header, data=data) if checkall.checkall('pd', i + 1, r.status_code, r.content) == 'pass': set.set_result(1, i + 1, 'pass') elif checkall.checkall('pd', i + 1, r.status_code, r.content) == 'fail': set.set_result(1, i + 1, 'fail') set.set_statuscode(1, i + 1, r.status_code) set.set_content(1, i + 1, r.content.decode('UTF-8')) set.set_sql(1, i + 1, checkdb.check('pd', i + 1)[1]) elif get.get_data('pd', i + 1, 3) == 'get': r = requests.get(url=url, headers=header, data=data) if checkall.checkall('pd', i + 1, r.status_code, r.content) == 'pass': set.set_result(1, i + 1, 'pass') elif checkall.checkall('pd', i + 1, r.status_code, r.content) == 'fail': set.set_result(1, i + 1, 'fail') set.set_statuscode(1, i + 1, r.status_code) set.set_content(1, i + 1, r.content.decode('UTF-8')) set.set_sql(1, i + 1, checkdb.check('pd', i + 1)[1]) elif int(get.get_data('pd', i + 1, 4)) == 0: print 'not execute' set.set_result(1, i + 1, 'not execute')
def setUp(self): self.driver = webdriver.Firefox() access.login(self.driver) self.driver.find_element(By.XPATH, '//a[text()="Översikt"]').click()
def setUp(self): self.driver = webdriver.Firefox() access.login(self.driver) self.driver.find_element(By.XPATH, '//a[text()="Ny bokning"]').click() self.wait = WebDriverWait(self.driver, 2)