Exemple #1
0
def cb_sample_entity_create(cb):
    """
    Configuring the CB Utility lib
    """
    attr = AttributesCreation()
    attr.add_attribute("temperature",
                       "centigrades",
                       value)
    ce = ContextElements()
    ce.add_context_element(entity_id, entity_type, attr)
    payload = PayloadUtils.build_standard_entity_creation_payload(ce)
    __logger__.debug(payload)

    r = cb.standard_entity_creation(payload)

    eq_(200, r.status_code)
    cb_content_json = json.loads(r.content)
    __logger__.debug(cb_content_json)
    eq_("200", cb_content_json["contextResponses"][0]["statusCode"]["code"],
        'INCORRECT STATUS CODE'
        '\n CB_CODE OBTAINED IS NOT == {} \n Received: {}'.format("200",
                                                                  cb_content_json["contextResponses"][0][
                                                                      "statusCode"][
                                                                      "code"]))
    eq_("OK", cb_content_json["contextResponses"][0]["statusCode"]["reasonPhrase"],
        'INCORRECT reason_Phrase.'
        '\n CB_Reason OBTAINED IS NOT == {} \n Received: {}'.format("OK",
                                                                    cb_content_json["contextResponses"][0][
                                                                        "statusCode"]["reasonPhrase"]))

    __logger__.info("#>> CommonLib: [CB] Entity created")

    return r