def test():

    com = Common()

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

    method = 'GET'
    url = com.get_customer_lims_ip() + 'welcome'
    headers = {}
    fields = {}

    print(url)
    print('------- issue the request -------')
    r = com.http.request(method=method,
                         url=url,
                         headers=headers,
                         fields=fields,
                         retries=False,
                         timeout=120.0)

    print('------- response is here -------')
    print(type(r))

    assert r.status == 200, "response has bad status"

    jdata = json.loads(r.data.decode('utf-8'))
    message = jdata['message']
    assert message == 'welcome'

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

    com = Common()

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

    method = 'GET'
    url = com.get_customer_lims_ip() + 'smtolims/postAssayStatus'
    headers = {}
    fields = {}

    print(url)
    print('------- issue the request -------')
    r = com.http.request(method=method,
                         url=url,
                         headers=headers,
                         fields=fields,
                         retries=False,
                         timeout=120.0)

    print('------- response is here -------')

    assert r.status == 200, "response has bad status"
    jdata = json.loads(r.data.decode('utf-8'))

    print('---------------')
    for x in jdata:
        print(x)

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

    com = Common()

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

    method = 'GET'
    url = com.get_cm_ip() + 'health/live'
    # url = com.CM_IP
    headers = {}
    fields = {}

    print('------- issue the request -------')
    r = com.http.request(method=method,
                         url=url,
                         headers=headers,
                         fields=fields,
                         retries=False,
                         timeout=120.0)

    print('------- response is here -------')
    print('r.headers = {}'.format(r.headers))
    print('r.status  = {}'.format(r.status))
    assert r.status == 200, "response has bad status"

    print('------- test done --------')
예제 #4
0
def test():

    com = Common()

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

    data = com.sm_retrieve_get_test_list(1)

    # the test checks to confirm at least one "40" and one "41" assay
    # these are presumed started by earlier tests
    found40 = False
    found41 = False
    for n, row in data.items():
        lims_id = row['lims_id']
        serial_number = row['serial_number']
        if lims_id[0:2] == '40':
            found40 = True
            print('------- found LIMS_ID {} serial number {}'.format(
                lims_id, serial_number))
        if lims_id[0:2] == '41':
            found41 = True
            print('------- found LIMS_ID {} serial number {}'.format(
                lims_id, serial_number))

    assert found40, 'the test was expecting an assay with LIMS_ID 40xxxxxx and did not find it'
    assert found41, 'the test was expecting an assay with LIMS_ID 41xxxxxx and did not find it'

    print('------- test is done -------')
예제 #5
0
def test():

    com = Common()

    print('------- start the test -------')
    
    com.sm_home_load(sm_number=1)

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

    com = Common()

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

    data = com.sm_approve_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] == '40':
            print(
                '------- using SM User interface to approve assay: LIMS_ID {} serial num {}'
                .format(lims_id, serial_number))

            com.sm_approve_approve_test_by_serial_number_or_lims_id(
                sm_number=1,
                by="lims_id",
                serial_number_or_lims_id=lims_id,
                test_comment=com.get_random_approve_comment(),
                oos_comment=com.get_random_approve_comment(),
                general_comment=com.get_random_approve_comment(),
                mold_count=com.get_random_approve_mold_count())

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

    com = Common()

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

    primary_ids = com.order_using_lims_web_api("case_0_lims_id", 1)
    print(primary_ids)
    ##time.sleep(10)
    com.cancel_from_primary_ids(primary_ids)

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

    com = Common()

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

    assert False, 'this test fails due to AZU 2186: order using only serial number (no LIMS_ID) is rejected'
    primary_ids = com.order_using_lims_web_api("case_2_serial_number", 5)
    print(primary_ids)
    ##time.sleep(10)
    com.cancel_from_primary_ids(primary_ids)

    print('------- test is done -------')
예제 #9
0
def test():

    com = Common()

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

    primary_ids = com.order_using_lims_web_api(
        'case_91_lims_id_plus_serial_number', 2)
    print(primary_ids)
    time.sleep(5)
    com.cancel_from_primary_ids(primary_ids)

    print('------- test is done -------')
예제 #10
0
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 --------')
def test():

    com = Common()

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

    primary_ids = com.order_using_lims_web_api(
        'case_91_lims_id_plus_serial_number', 2)
    print(primary_ids)

    # time.sleep(5)
    # print('------- load -------')
    # com.sm_home_load(sm_number=1)

    print('------- test is done -------')
예제 #12
0
def test():

    com = Common()

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

    tries_remaining = 30
    while tries_remaining > 0:

        data = com.sm_home_get_test_list(1)

        # the test checks to confirm at least one "40" and one "41" assay
        # these are presumed started by earlier tests
        found40 = False
        found41 = False
        found42 = False
        for n, row in data.items():
            lims_id = row['lims_id']
            serial_number = row['serial_number']

            # workaround in case we don't get complete status from UI... zona
            if 'status' in row:
                if row['status'] == 'Ordered' and lims_id[0:2] == '40':
                    found40 = True
                    print('------- found LIMS_ID {} serial number {}'.format(
                        lims_id, serial_number))
                if row['status'] == 'Ordered' and lims_id[0:2] == '41':
                    found41 = True
                    print('------- found LIMS_ID {} serial number {}'.format(
                        lims_id, serial_number))
                if row['status'] == 'Ordered' and lims_id[0:2] == '42':
                    found42 = True
                    print('------- found LIMS_ID {} serial number {}'.format(
                        lims_id, serial_number))

        if found40 and found41 and found42:
            break
        else:
            tries_remaining -= 1
            print('------- waiting for ordered... 40={} 41={} 42={} -------'.
                  format(found40, found41, found42))
            time.sleep(1)

    assert found40, 'the test was expecting an assay with LIMS_ID 40xxxxxx and did not find it'
    assert found41, 'the test was expecting an assay with LIMS_ID 41xxxxxx and did not find it'
    assert found42, 'the test was expecting an assay with LIMS_ID 42xxxxxx and did not find it'

    print('------- test is done -------')
예제 #13
0
def test():

    com = Common()

    print('------- start the test -------')
    
    assert False, "design does not support LIMS approve (receipt)"
    
    print('------- test is done -------')
def test():

    com = Common()

    print('------- start the test -------')
 
    tries_remaining = 30
    while tries_remaining > 0:
        data = com.sm_home_get_test_list(1)
        done = com.no_assays_in_any_of_the_following_states(
            actual_states=data,
            unacceptable_states=['Ordered'])
        if done:
            break
        else:
            tries_remaining-=1
            print('------- one or more assays with status=[Ordered]. Will wait. tries_remaining={} -------'.format(tries_remaining))
            time.sleep(1)

    assert tries_remaining > 0, "timeout waiting for assay status"

    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 --------')
예제 #16
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 --------')
예제 #17
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 -------')
예제 #18
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 --------')
def test():

    com = Common()

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

    method = 'POST'
    url = com.get_cm_ip() + 'auth/login'
    headers = {
        'Content-Type': 'application/json',
        }

    password_cleartext = 'test@123'
    #md5_obj = hashlib.md5(password_cleartext)
    #password_md5 = md5_obj.hexdigest()
    #password_md5 = md5_obj.digest()

    fields = {}
    body_raw = {
        'userName': '******',
        'password': password_cleartext,
    }
    body_encoded = json.dumps(body_raw).encode('utf-8')

    print('------- the request is --------')
    print('method={}'.format(method))
    print('url={}'.format(url))
    print('headers={}'.format(headers))
    print('fields={}'.format(fields))
    print('body={}'.format(body_encoded))



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

    print('------- response is here -------')
    print('r.headers = {}'.format(r.headers))
    print('r.status  = {}'.format(r.status))
    print('r.data    = {}'.format(r.data))

    # check response status == 200
    assert r.status == 200, "response has bad status"

    # check the auth token is the right length
    jdata = json.loads(r.data.decode('utf-8'))
    token = jdata['authToken']
    print("------------here")
    print(type(token))

    assert len(token) == com.AUTH_TOKEN_EXPECTED_LENGTH_FROM_CM, 'auth token length: expected {}, observed {}'.format(
        com.AUTH_TOKEN_EXPECTED_LENGTH_FROM_CM,
        len(token))

    bearer_token = 'Bearer ' + token
    print('----------')
    print(bearer_token)
    print('------- test done --------')