コード例 #1
0
def created_subscription(step, server_id):

    world.tenant_id = TENANT_ID
    world.server_id = server_id
    world.headers = HEADERS

    world.rule_body = Rule_Utils.create_scale_specific_rule()

    # Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=world.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    # Save the Rule ID to obtain the Rule information after
    world.rule_id = req.json()[RULE_ID]

    req = api_utils.create_subscription(
        tenant_id=world.tenant_id,
        server_id=world.server_id,
        rule_id=world.rule_id,
        url=RULE_URL_DEFAULT,
        headers=world.headers,
    )

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
    print req.content
    world.subscription_id = req.json()[SUBSCRIPTION_ID]
コード例 #2
0
ファイル: subscriptions.py プロジェクト: cgc951/fiware-cloto
def created_subscription(context, server_id):

    context.tenant_id = TENANT_ID
    context.server_id = server_id
    context.headers = HEADERS

    context.rule_body = Rule_Utils.create_scale_specific_rule()

    # Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=context.tenant_id,
                                server_id=context.server_id,
                                body=context.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    # Save the Rule ID to obtain the Rule information after
    context.rule_id = req.json()[RULE_ID]

    req = api_utils.create_subscription(tenant_id=context.tenant_id,
                                        server_id=context.server_id,
                                        rule_id=context.rule_id,
                                        url=RULE_URL_DEFAULT,
                                        headers=context.headers)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
    print(req.content)
    context.subscription_id = req.json()[SUBSCRIPTION_ID]
コード例 #3
0
def assert_rule_saved(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = world.req.json()
    assert_equals(response[SERVER_ID], world.server_id, INCORRECT_SERVER_ID.format(world.server_id,
                                                                                   response[SERVER_ID]))
    assert_in(RULE_ID, response.keys(), INVALID_JSON.format(response))
コード例 #4
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def assert_rule_saved(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = world.req.json()
    assert_equals(response[SERVER_ID], world.server_id, INCORRECT_SERVER_ID.format(world.server_id,
                                                                                   response[SERVER_ID]))
    assert_in(RULE_ID, response.keys(), INVALID_JSON.format(response))
コード例 #5
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def given_a_group1_of_servers_in_a_tenant(step, number_servers):

    world.number_servers = int(number_servers)
    world.servers_body = []

    for x in range(world.number_servers):
        world.rules = []
        server_id = Utils.id_generator(size=6)
        number_rules = random.randint(1, 5)

        for rule in range(number_rules):
            rule_body = Rule_Utils.create_scale_specific_rule()
            req = api_utils.create_rule(world.tenant_id,
                                        server_id,
                                        body=rule_body)
            assert_true(req.ok,
                        HTTP_CODE_NOT_OK.format(req.status_code, req.content))
            rule_id = req.json()[RULE_ID]
            world.rules.append(
                Rule_Utils.create_rule_body(action=None,
                                            rule_id=rule_id,
                                            condition=None,
                                            name=rule_body['name']))

        server_dict = {SERVER_ID: server_id, RULES: world.rules}
        world.servers_body.append(server_dict)
コード例 #6
0
ファイル: subscriptions.py プロジェクト: Fiware/cloud.Cloto
def assert_subscription_is_deleted(context):

    assert_true(context.req.ok, HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))
    req = api_utils.retrieve_subscription(tenant_id=context.tenant_id, server_id=context.server_id,
                                          subscription_id=context.subscription_id, headers=context.headers)
    Utils.assert_error_code_error(response=req, expected_error_code='404',
                                  expected_fault_element=ITEM_NOT_FOUND_ERROR)
コード例 #7
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def then_i_obtain_zero_results(step):

    assert_true(
        world.req.ok,
        HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    assert_equals(response[SERVERS], [])
コード例 #8
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def then_i_obtain_the_server_list(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    for results in world.servers_body:
        assert_in(results, response[SERVERS])
    Utils.delete_all_rules_from_tenant()
コード例 #9
0
def then_i_obtain_the_server_list(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    for results in world.servers_body:
        assert_in(results, response[SERVERS])
    Utils.delete_all_rules_from_tenant()
コード例 #10
0
ファイル: rules.py プロジェクト: Fiware/cloud.Cloto
def assert_rule_is_deleted(context):

    assert_true(context.req.ok, HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))

    req = api_utils.retrieve_rule(tenant_id=context.tenant_id, server_id=context.server_id, rule_id=context.rule_id,
                                  headers=context.headers)

    assert_equals(req.status_code, 404, ERROR_CODE_ERROR.format(req.status_code, 404))
コード例 #11
0
ファイル: subscriptions.py プロジェクト: cgc951/fiware-cloto
def assert_subscription_created(context):

    assert_true(
        context.req.ok,
        HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))
    response = Utils.assert_json_format(context.req)
    assert_equals(response[SERVER_ID], context.server_id)
    assert_in(SUBSCRIPTION_ID, response.keys())
コード例 #12
0
def assert_subscription_information(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    assert_equals(response[RULE_URL], RULE_URL_DEFAULT)
    assert_equals(response[SERVER_ID], world.server_id)
    assert_equals(response[SUBSCRIPTION_ID], world.subscription_id)
    assert_equals(response[RULE_ID], world.rule_id)
コード例 #13
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def assert_rule_information(step):

    assert_true(
        world.req.ok,
        HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    Rule_Utils.assert_rule_information(response=response,
                                       rule_id=world.rule_id,
                                       body=world.rule_body)
コード例 #14
0
ファイル: subscriptions.py プロジェクト: cgc951/fiware-cloto
def assert_subscription_information(context):

    assert_true(
        context.req.ok,
        HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))
    response = Utils.assert_json_format(context.req)
    assert_equals(response[RULE_URL], RULE_URL_DEFAULT)
    assert_equals(response[SERVER_ID], context.server_id)
    assert_equals(response[SUBSCRIPTION_ID], context.subscription_id)
    assert_equals(response[RULE_ID], context.rule_id)
コード例 #15
0
def given_group1_of_rules_created_in_group2(step, number_rules, server_id):

    world.server_id = server_id
    world.number_rules = int(number_rules)
    for x in range(world.number_rules):
        rule_body = Rule_Utils.create_notify_specific_rule()
        req = api_utils.create_rule(world.tenant_id, world.server_id, body=rule_body)
        assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
        rule_id = req.json()[RULE_ID]
        world.rules.append(rule_body)
コード例 #16
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def given_group1_of_rules_created_in_group2(step, number_rules, server_id):

    world.server_id = server_id
    world.number_rules = int(number_rules)
    for x in range(world.number_rules):
        rule_body = Rule_Utils.create_notify_specific_rule()
        req = api_utils.create_rule(world.tenant_id, world.server_id, body=rule_body)
        assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
        rule_id = req.json()[RULE_ID]
        world.rules.append(rule_body)
コード例 #17
0
def assert_rule_information(context):

    assert_true(
        context.req.ok,
        HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))

    response = Utils.assert_json_format(context.req)
    Rule_Utils.assert_rule_information(response=response,
                                       rule_id=context.rule_id,
                                       body=context.rule_body)
コード例 #18
0
def assert_subscription_is_deleted(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    req = api_utils.retrieve_subscription(
        tenant_id=world.tenant_id,
        server_id=world.server_id,
        subscription_id=world.subscription_id,
        headers=world.headers,
    )
    Utils.assert_error_code_error(response=req, expected_error_code="404", expected_fault_element=ITEM_NOT_FOUND_ERROR)
コード例 #19
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def assert_rule_is_deleted(step):

    assert_true(
        world.req.ok,
        HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    req = api_utils.retrieve_rule(tenant_id=world.tenant_id,
                                  server_id=world.server_id,
                                  rule_id=world.rule_id,
                                  headers=world.headers)
    assert_equals(req.status_code, 404,
                  ERROR_CODE_ERROR.format(req.status_code, 404))
コード例 #20
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def created_rule(step, server_id):

    world.server_id = server_id
    world.rule_body = Rule_Utils.create_scale_specific_rule()

    #Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=world.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    #Save the Rule ID to obtain the Rule information after
    world.rule_id = req.json()[RULE_ID]
コード例 #21
0
def created_rule(step, server_id):

    world.server_id = server_id
    world.rule_body = Rule_Utils.create_scale_specific_rule()

    #Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=world.tenant_id, server_id=world.server_id, body=world.rule_body)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))

    #Save the Rule ID to obtain the Rule information after
    world.rule_id = req.json()[RULE_ID]
コード例 #22
0
ファイル: subscriptions.py プロジェクト: cgc951/fiware-cloto
def assert_subscription_is_deleted(context):

    assert_true(
        context.req.ok,
        HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))
    req = api_utils.retrieve_subscription(
        tenant_id=context.tenant_id,
        server_id=context.server_id,
        subscription_id=context.subscription_id,
        headers=context.headers)
    Utils.assert_error_code_error(response=req,
                                  expected_error_code='404',
                                  expected_fault_element=ITEM_NOT_FOUND_ERROR)
コード例 #23
0
ファイル: rule_utils.py プロジェクト: cgc951/fiware-cloto
def create_rule(api_utils, tenant_id=TENANT_ID, server_id=None, rule_body=None, headers=HEADERS):

    """Method to subscribe a server to a specific rule not created.
    :param server_id: Server unique identifier
    :param headers: HTTP headers for the requests including authentication
    :param tenant_id: Tenant unique identifier
    :returns subscription_id: Subscription unique identifier
    """

    #Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=tenant_id, server_id=server_id, body=rule_body, headers=headers)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code))

    rule_id = req.json()[RULE_ID]
    return rule_id
コード例 #24
0
ファイル: rule_utils.py プロジェクト: geonexus/fiware-cloto
def create_rule(api_utils, tenant_id=TENANT_ID, server_id=None, rule_body=None, headers=HEADERS):

    """Method to subscribe a server to a specific rule not created.
    :param server_id: Server unique identifier
    :param headers: HTTP headers for the requests including authentication
    :param tenant_id: Tenant unique identifier
    :returns subscription_id: Subscription unique identifier
    """

    # Create the rule in Policy Manager
    req = api_utils.create_rule(tenant_id=tenant_id, server_id=server_id, body=rule_body, headers=headers)

    assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code))

    rule_id = req.json()[RULE_ID]
    return rule_id
コード例 #25
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def given_a_group1_of_servers_in_a_tenant(step, number_servers):

    world.number_servers = int(number_servers)
    world.servers_body = []

    for x in range(world.number_servers):
        world.rules = []
        server_id = Utils.id_generator(size=6)
        number_rules = random.randint(1, 5)

        for rule in range(number_rules):
            rule_body = Rule_Utils.create_scale_specific_rule()
            req = api_utils.create_rule(world.tenant_id, server_id, body=rule_body)
            assert_true(req.ok, HTTP_CODE_NOT_OK.format(req.status_code, req.content))
            rule_id = req.json()[RULE_ID]
            world.rules.append(Rule_Utils.create_rule_body(action=None, rule_id=rule_id, condition=None,
                                                           name=rule_body['name']))

        server_dict = {SERVER_ID: server_id,
                       RULES: world.rules}
        world.servers_body.append(server_dict)
コード例 #26
0
ファイル: rules.py プロジェクト: Fiware/cloud.Cloto
def assert_rule_information(context):

    assert_true(context.req.ok, HTTP_CODE_NOT_OK.format(context.req.status_code, context.req.content))

    response = Utils.assert_json_format(context.req)
    Rule_Utils.assert_rule_information(response=response, rule_id=context.rule_id, body=context.rule_body)
コード例 #27
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def then_i_obtain_zero_results(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    assert_equals(response[SERVERS], [])
コード例 #28
0
ファイル: rules.py プロジェクト: carloslucenah/fiware-cloto
def assert_rule_information(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    Rule_Utils.assert_rule_information(response=response, rule_id=world.rule_id, body=world.rule_body)
コード例 #29
0
def assert_subscription_created(step):

    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code, world.req.content))
    response = Utils.assert_json_format(world.req)
    assert_equals(response[SERVER_ID], world.server_id)
    assert_in(SUBSCRIPTION_ID, response.keys())
コード例 #30
0
ファイル: steps.py プロジェクト: FiwareULPGC/fiware-cloto
def then_the_context_is_updated(step):

    print world.req.content
    assert_true(world.req.ok, HTTP_CODE_NOT_OK.format(world.req.status_code))