def test():

    com = Common()

    print('------- start test -------')

    token = com.get_auth_token()

    # check the auth token is the right length
    assert len(token) == com.AUTH_TOKEN_EXPECTED_LENGTH_TO_CM, 'auth token length: expected {}, observed {}'.format(
        com.AUTH_TOKEN_EXPECTED_LENGTH_TO_CM,
        len(token))

    print('------- test done --------')
Example #2
0
def test():

    com = Common()

    print('------- get the token -------')

    token_raw = com.get_auth_token()
    [y, token_value] = token_raw.split()

    print('------- create the LIMS order request -------')

    method = 'POST'
    url = com.get_cm_ip() + 'lims/postOrder'

    # this test will create three orders with preface of [40,41,42] for LIMS_ID and SERIAL_NUMBER
    # the three tests will be later cancelled by later tests

    for prefix in ['40', '41', '42']:

        lims_id_generic = com.get_unique_lims_id()
        lims_id_specific = prefix + lims_id_generic[2:]

        # serial_number_generic = com.get_unique_serial_number_em_bb()
        # serial_number_specific = serial_number_generic[0] + prefix + serial_number_generic[3:]
        serial_number_specific = ""

        # sample_id = "s10000"  # hard code sample id
        sample_id = ""

        # lot_batch_id = "B11"
        lot_batch_id = ""

        headers = {
            'accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': token_raw,
        }

        fields = {}

        body_raw = {
            "instr_id": com.get_sm_inst_id(1),
            "lims_id": lims_id_specific,
            "serial_number": serial_number_specific,
            "sample_id": sample_id,
            "lot_batch_id": lot_batch_id,
            "method_name": '',
            "handling_rule_name": '',
            "action_alert_level_name": '',
            "aal_cfu_threshold_alert": '',
            "aal_cfu_threshold_action": '',
            "aal_cfu_threshold_specification": '',
            "aal_cfu_threshold_pass": '',
            "comment": com.get_random_comment_order(),
        }

        print('--------------body raw-----------------')
        print(body_raw)

        body_encoded = json.dumps(body_raw).encode('utf-8')

        print('------- issue the LIMS order request to CM -------')
        r = com.http.request(method=method,
                             url=url,
                             headers=headers,
                             fields=fields,
                             body=body_encoded,
                             retries=False,
                             timeout=120.0)

        print('------- response from CM is here -------')
        print('r.headers =\n{}'.format(r.headers))
        print('r.status  =\n{}'.format(r.status))
        print('r.data    =\n{}'.format(r.data))
        assert r.status == 200, "response has bad status: expected 200 observed {}".format(
            r.status)

    print('------- test done --------')
Example #3
0
def test():

    com = Common()

    print('------- get the token -------')

    token = com.get_auth_token()

    print('------- create the LIMS cancel request -------')

    data = com.sm_retrieve_get_test_list(1)

    for n, row in data.items():
        lims_id = row['lims_id']
        serial_number = row['serial_number']

        if lims_id[0:2] == '42':
            print('------- using LIMS Cancel command to cancel assay: LIMS_ID {} serial num {}'.format(lims_id, serial_number))

            method = 'POST'
            url = com.get_cm_ip() + 'lims/postCancel'
    
            headers = {
                'accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': token,
                }

            fields = {}

            body_raw = {
                "instr_id": com.get_sm_inst_id(1),
                "lims_id": lims_id,
                "serial_number": '',
                "sample_id": '',
                "lot_batch_id": '',
                }

            body_encoded = json.dumps(body_raw).encode('utf-8')

            print('------- issue the LIMS cancel request to CM -------')
            r = com.http.request(
                method=method,
                url=url,
                headers=headers,
                fields=fields,
                body=body_encoded,
                retries=False,
                timeout=120.0)

            print('------- response from CM is here -------')
            assert r.status == 200, "response has bad status"

            print('------- test done --------')













    print('------- test is done -------')
def test():

    com = Common()

    print('------- get the token -------')

    token_raw = com.get_auth_token()

    print('------- create the LIMS order request -------')

    method = 'POST'
    url = com.get_cm_ip() + 'lims/postOrder'

    instr_id = com.get_sm_inst_id(1)
    lims_id = com.get_unique_lims_id()
    serial_number = ""
    lot_batch = ""
    sample_id = ""
    mm = "mm10000"
    aa = "aa"
    hr = "hr"

    headers = {
        'accept': 'application/json',
        'Content-Type': 'application/json',
        'Authorization': token_raw,
        }

    fields = {}

    body_raw = {
        "instr_id": instr_id,
        "lims_id": lims_id,
        "serial_number": serial_number,
        "sample_id": sample_id,
        "lot_batch_id": lot_batch,
        "method_name": mm,
        "handling_rule_name": hr,
        "action_alert_level_name": aa,
        "aal_cfu_threshold_alert": '',
        "aal_cfu_threshold_action": '',
        "aal_cfu_threshold_specification": '',
        "aal_cfu_threshold_pass": '',
        "comment": com.get_random_comment_order(),
        }

    print('--------------body raw-----------------')
    print(body_raw)

    body_encoded = json.dumps(body_raw).encode('utf-8')

    print('------- issue the LIMS order request to CM -------')
    r = com.http.request(
        method=method,
        url=url,
        headers=headers,
        fields=fields,
        body=body_encoded,
        retries=False,
        timeout=120.0)

    print('------- response from CM is here -------')
    print('r.headers =\n{}'.format(r.headers))
    print('r.status  =\n{}'.format(r.status))
    print('r.data    =\n{}'.format(r.data))
    assert r.status == 200, "response has bad status: expected 200 observed {}".format(r.status)




    print('------- test done --------')
Example #5
0
def test():

    com = Common()

    print('------- get the token -------')

    token_raw = com.get_auth_token()

    print('------- create the LIMS order request -------')

    method = 'POST'
    url = com.get_cm_ip() + 'lims/postOrder'

    instr_id = com.get_sm_inst_id(1)
    lims_id = com.get_unique_lims_id()
    serial_number = ""
    lot_batch = ""
    sample_list = [
        '', ''
    ]  # note - this is the error case - multiple tests ordered using same LIMS_ID and no sample - first should be accepted second should be rejected
    mm = "mm10000"
    aa = "aa"
    hr = "hr"

    loop_num = 0
    for sample_id in sample_list:

        # junky sleep so can figure out the SM logfiles which loop it is
        loop_num += 1
        import time
        time.sleep(3)

        headers = {
            'accept': 'application/json',
            'Content-Type': 'application/json',
            'Authorization': token_raw,
        }

        fields = {}

        body_raw = {
            "instr_id": instr_id,
            "lims_id": lims_id,
            "serial_number": serial_number,
            "sample_id": sample_id,
            "lot_batch_id": lot_batch,
            "method_name": mm,
            "handling_rule_name": hr,
            "action_alert_level_name": aa,
            "aal_cfu_threshold_alert": '',
            "aal_cfu_threshold_action": '',
            "aal_cfu_threshold_specification": '',
            "aal_cfu_threshold_pass": '',
            "comment": com.get_random_comment_order(),
        }

        print('--------------body raw-----------------')
        print(body_raw)

        body_encoded = json.dumps(body_raw).encode('utf-8')

        print('------- issue the LIMS order request to CM -------')
        r = com.http.request(method=method,
                             url=url,
                             headers=headers,
                             fields=fields,
                             body=body_encoded,
                             retries=False,
                             timeout=120.0)

        print('------- response from CM is here -------')
        print('r.headers =\n{}'.format(r.headers))
        print('r.status  =\n{}'.format(r.status))
        print('r.data    =\n{}'.format(r.data))
        if loop_num == 1:
            assert r.status == 200, "response has bad status: expected 200 observed {}".format(
                r.status)
        if loop_num == 2:
            assert r.status != 200, "response has GOOD status: expected !200 observed {}".format(
                r.status)

    print('------- test done --------')