コード例 #1
0
ファイル: step_crud.py プロジェクト: dmitrykurguz/directual
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
コード例 #2
0
ファイル: step_crud.py プロジェクト: dmitrykurguz/directual
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
コード例 #3
0
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
コード例 #4
0
ファイル: step_crud.py プロジェクト: dmitrykurguz/directual
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
コード例 #5
0
ファイル: step_crud.py プロジェクト: dmitrykurguz/directual
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
コード例 #6
0
def getVersions(context, struct_name, object_id, version=0):
    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))

    #http://localhost:8081/good/api/v3/object/data/4283/?sessionid=34212c47-86b0-4671-943b-9b5f7920e15d
    #{"sessionid":"34212c47-86b0-4671-943b-9b5f7920e15d","history":true,"version":0,"structID":"test","objectID":"1","showLinkName":true}

    uri = '%s/good/api/v3/object/data/0/?appID=%s&appSecret=%s' % (
        appAddress(context), app_id, app_secret)

    # body = context.text
    body = '{"history": true, "version": %s, "structID": "%s", "objectID": "%s", "showLinkName": true}' % (
        version, struct_name, object_id)

    debug('call: %s' % uri, body)
    res = requests.post(uri, data=body)
    handleResponse(res)

    # TODO
    response = json.loads(res.text)
    return response
コード例 #7
0
def step_impl(context, path):
  print(context.browser.current_url)
  result_path = appAddress(context) + path
  assert result_path in context.browser.current_url