def step_impl(context, struct_name, struct_id): try: # time.sleep(5) # FIXME remove it ! app_id = paramFromConfig(context, 'app_id') app_secret = paramFromConfig(context, 'app_secret') debug('use app_id %s and app_secret %s' % (app_id, app_secret)) body = '{"filters":[{"operator":"AND","field":"id","value":"%s","exp":"="}],"fetch":"","fields":"","pageSize":10,"page":0,"ref":"","allObjects":true,"orders":[]}' % struct_id uri = '%s/good/api/v3/struct/%s/search/?appID=%s&appSecret=%s' % ( appAddress(context), struct_name, app_id, app_secret) debug('call: %s' % uri, body) res = requests.post(uri, data=body) debug(res.text) # handleResponse(res) response = json.loads(res.text) # debug(response) # TODO try to uncoment, it's object, check alive test! assert 'result' in response results = response['result'] assert 'list' in results assert len(results['list']) == 1 except AssertionError as ex: raise ex except Exception: logError() assert False
def step_impl(context, struct_name): try: app_id = paramFromConfig(context, 'app_id') app_secret = paramFromConfig(context, 'app_secret') step_params = json.loads(context.text) filters = step_params['filter'] assertion = flatten_json(step_params['assert']) uri = '%s/good/api/v3/struct/%s/search/?appID=%s&appSecret=%s' % ( appAddress(context), struct_name, app_id, app_secret) debug('looking %s with filters: %s' % (struct_name, filters)) body = json.dumps(filters) debug('call: %s' % uri, body) r = requests.post(uri, data=body) handleResponse(r) result = json.loads(r.text) resultList = result['result']['list'] assert len(resultList) == 1 item = resultList[0]['obj'] debug('item = %s' % item) debug(assertion) flattenItem = flatten_json(item) for assertKey, assertValue in assertion.items(): assert flattenItem[assertKey] == assertValue except AssertionError as ex: raise ex except Exception: logError() assert False
def step_impl(context, path): try: context.browser.get(appAddress(context) + path) allure.attach(context.browser.get_screenshot_as_png(), name='open_page_%s' % path, attachment_type=allure.attachment_type.PNG) except Exception: logError() assert False
def step_impl(context, struct_name, object_id, versions_count): try: response = getVersions(context, struct_name, object_id) assert 'result' in response history = response['result']['history'] assert len(history) == versions_count except AssertionError as ex: raise ex except Exception: logError() assert False
def step_impl(context, path): try: sessionid = readCookieFromCache("sessionid") assert sessionid is not None uri = '%s%s?%s=%s' % (appAddress(context), path, 'sessionid', sessionid['value']) debug('request %s with sessionId' % uri) r = requests.post(uri, data=context.text) handleResponse(r) except AssertionError as ex: raise ex except Exception: logError() assert False
def step_impl(context, struct_name): try: app_id = paramFromConfig(context, 'app_id') app_secret = paramFromConfig(context, 'app_secret') debug('use app_id %s and app_secret %s' % (app_id, app_secret)) uri = '%s/good/api/v3/struct/%s/?appID=%s&appSecret=%s' % ( appAddress(context), struct_name, app_id, app_secret) body = context.text debug('call: %s' % uri, body) res = requests.post(uri, data=body) handleResponse(res) result = json.loads(res.text) assert 'msg' not in result except AssertionError as ex: raise ex except Exception: logError() assert False