def test_restricted_params(): number = IVR.get_random_number_for_reserve() id = '10777' params = [ { "orderName": random_generator(256), "orderDescription": "sad", "orderItemNumber": str(number), "orderItemDescription": "wrongbuy" }, { "orderName": random_generator(255), "orderDescription": random_generator(256), "orderItemNumber": str(number), "orderItemDescription": "wrongbuy" }, { "orderName": random_generator(100), "orderDescription": "ssad", "orderItemNumber": random_generator(129), "orderItemDescription": "wrongbuy" }, { "orderName": random_generator(100), "orderDescription": "sad", "orderItemNumber": str(number), "orderItemDescription": random_generator(256) } ] for case in params: r = IVR.add_resource(data['login'], data['password'], id, case) assert r.status_code == 400
def test_add_resource_to_customer(): number = IVR.get_random_number_for_reserve() query = connectors.search_record_postgres('SELECT cmgtc.id,cmgtc.name from customer_mgt.customer as cmgtc ' 'LEFT JOIN customer_mgt.characteristic as cmc ' 'ON cmgtc.id = cmc.characteristic_customer_id ' 'WHERE cmgtc.status = %(status)s and cmc.name = \'billingId\'', {'status': 'active'}) random_record = random.choice(query) id = random_record[0] # customer_name = random_record[1] params = { "orderName": random_generator(255), "orderDescription": random_generator(255), "orderItemNumber": random_generator(128), "orderItemDescription": IVR.random_generator(255) } r = IVR.add_resource(data['login'], data['password'], id, params) assert r.status_code == 201 if r.status_code == 500: response = r.json() print(response['message']) response = r.json() assert response['id'] assert params['orderName'] == response['orderName'] assert params['orderDescription'] == response['orderDescription'] assert params['orderItemNumber'] == response['orderItemNumber'] assert params['orderItemDescription'] == response['orderItemDescription']
def test_unique_params(): number = IVR.get_random_number_for_reserve() id = data['customer_id'] params = { "orderName": "zakzak", "orderItemNumber": str(number) + random_generator(5) } r = IVR.add_resource(data['login'], data['password'], id, params) assert r.status_code == 201 r = IVR.add_resource(data['login'], data['password'], id, params) assert r.status_code == 409
def test_invalid_customer_id(): number = IVR.get_random_number_for_reserve() id = 'dsm' params = { "orderName": "trewt", "orderDescription": "sad", "orderItemNumber": str(number), "orderItemDescription": "wrongbuy" } r = IVR.add_resource(data['login'], data['password'], id, params) assert r.status_code == 400
def test_check_period(): number = IVR.get_random_number_for_reserve() params = {'number': number, 'period': 10} r = IVR.reserve_number(data['login'], data['password'], params) assert r.status_code == 201 response = r.json() assert 'reserved_uid' in response[0] reserved_uid = response[0]['reserved_uid'] r = get_number_info(number) assert r['result'][0]['state_name'] == "RESERVED" time.sleep(params['period']) r = get_number_info(number) assert r['result'][0]['state_name'] == "FREE"
def test_reserve_and_unreserve_correct_number(): number = IVR.get_random_number_for_reserve() params = {'number': str(number), 'period': 600} r = IVR.reserve_number(data['login'], data['password'], params) assert r.status_code == 201 response = r.json() assert 'reserved_uid' in response[0] reserved_uid = response[0]['reserved_uid'] r = get_number_info(number) assert r['result'][0]['state_name'] == "RESERVED" delete_params = {'number': str(number), 'reserved_uid': reserved_uid} r = IVR.delete_reserved_number(data['login'], data['password'], delete_params) assert r.status_code == 204 r = get_number_info(number) assert r['result'][0]['state_name'] == "FREE"
def test_missing_required_params(): number = IVR.get_random_number_for_reserve() id = '10777' params = [ { "orderName": "", "orderItemNumber": str(number), }, { "orderName": "vsa", "orderItemNumber": "", } ] for case in params: r = IVR.add_resource(data['login'], data['password'], id, case) assert r.status_code == 400
def test_wrong_type_params(): number = IVR.get_random_number_for_reserve() id = '10777' params = [ { "orderName": 900, "orderItemNumber": str(number), "orderItemDescription": "wrongbuy" }, { "orderName": "dsad", "orderItemNumber": int(number), "orderItemDescription": "wrongbuy" }, { "orderName": "dsad", "orderItemNumber": str(number), "orderItemDescription": 770 } ] for case in params: r = IVR.add_resource(data['login'], data['password'], id, case) assert r.status_code == 400
def test_reserve_broken_number(): number = IVR.get_random_number_for_reserve() params_400 = [ { 'number': int(number), 'period': 600 }, { 'number': str(number), 'period': '700' }, ], params_500 = [{ 'number': str(number) + '1', 'period': 600 }, { 'period': 700 }] for param in params_400: r = IVR.reserve_number(data['login'], data['password'], param) assert r.status_code == 400 for param in params_500: r = IVR.reserve_number(data['login'], data['password'], param) assert r.status_code == 500