예제 #1
0
def then_the_attributes_product_are_empty(step):

    assert_true(world.response.ok)
    response_headers = world.response.headers

    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        assert_equals(world.response.json(), None)

    else:
        response_body = xml_to_dict(world.response.content)
        assert_equals(response_body[PRODUCT_ATTRIBUTES], None)
예제 #2
0
    world.response = api_utils.add_product_release(headers=world.headers, body=body, product_id=product_name)


@step(u'Then the product release is created')
def then_the_product_release_is_created(step):

    assert_true(world.response.ok, world.response.content)
    response_headers = world.response.headers
    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        try:
            response_body = world.response.json()
        except Exception, e:
            print str(e)

    else:
        response_body = xml_to_dict(world.response.content)[PRODUCT_RELEASE]

    assert_equals(response_body[VERSION], world.product_release)
    world.headers = set_default_headers(world.token_id, world.tenant_id)


@step(u'Then I obtain an "([^"]*)"')
def then_i_obtain_an_group1(step, error_code):

    assert_equals(str(world.response.status_code), error_code, world.response.status_code)
    world.headers = set_default_headers(world.token_id, world.tenant_id)


@step(u'And incorrect "([^"]*)" header')
def and_incorrect_content_type_header(step, content_type):
    world.headers[CONTENT_TYPE] = content_type

@step(u'Then the product release list is received')
def then_the_product_release_list_is_received(step):

    assert_true(world.response.ok)
    response_headers = world.response.headers

    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        try:
            response_body = world.response.json()[PRODUCT_RELEASE]
        except Exception, e:
            print str(e)

    else:
        response_body = xml_to_dict(world.response.content)['productReleases'][PRODUCT_RELEASE]

    print response_body
    assert_equals(response_body[VERSION], world.product_release)
    assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name)


@step(u'Then no product releases are received')
def then_no_product_releases_are_received(step):

    assert_true(world.response.ok)
    response_headers = world.response.headers
    print world.response.content
    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        assert_equals('null', world.response.content)
    else:
예제 #4
0

@step(u'Then the product is retrieved')
def then_the_product_is_retrieved(step):

    assert_true(world.response.ok)
    response_headers = world.response.headers

    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        try:
            response_body = world.response.json()
        except Exception, e:
            print str(e)

    else:
        response_body = xml_to_dict(world.response.content)[PRODUCT]

    assert_equals(response_body[PRODUCT_NAME], world.created_product_body[PRODUCT][PRODUCT_NAME])
    assert_equals(response_body[PRODUCT_DESCRIPTION], world.created_product_body[PRODUCT][PRODUCT_DESCRIPTION])

    if world.attributes is not None:

        assert_equals(world.created_product_body[PRODUCT][PRODUCT_ATTRIBUTES], response_body[PRODUCT_ATTRIBUTES])
        world.attributes = None

    if world.metadatas is not None:
        for metadata in world.created_product_body[PRODUCT][PRODUCT_METADATAS]:
            assert_in(metadata, response_body[PRODUCT_METADATAS])
        world.metadatas = None

예제 #5
0

@step(u'Then the product release list is received')
def then_the_product_release_list_is_received(step):

    assert_true(world.response.ok)
    response_headers = world.response.headers

    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        try:
            response_body = world.response.json()[PRODUCT_RELEASE]
        except Exception, e:
            print str(e)

    else:
        response_body = xml_to_dict(
            world.response.content)['productReleases'][PRODUCT_RELEASE]

    print response_body
    assert_equals(response_body[VERSION], world.product_release)
    assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name)


@step(u'Then no product releases are received')
def then_no_product_releases_are_received(step):

    assert_true(world.response.ok)
    response_headers = world.response.headers
    print world.response.content
    if response_headers[CONTENT_TYPE] == CONTENT_TYPE_JSON:
        assert_equals('null', world.response.content)
    else: