Ejemplo n.º 1
0
def test_delete_resource_to_customer():
    params = {
        "orderName": random_generator(255),
        "orderDescription": random_generator(255),
        "orderItemNumber": random_generator(128),
        "orderItemDescription": random_generator(255)
    }
    r = IVR.add_resource(data['login'], data['password'], customer_id, params)
    assert r.status_code == 201
    bearer_token = IVR.take_token(data['login'], data['password'])
    r = IVR.get_customer_numbers(bearer_token, customer_id)
    assert r.status_code == 206
    response = r.json()
    id_number = 0
    for number in response:
        if number['number'] == params["orderItemNumber"]:
            id_number = number["id"]
            break
    r = IVR.delete_customer_numbers(data['login'], data['password'],
                                    customer_id, id_number)
    assert r.status_code == 204
    r = IVR.get_customer_numbers(bearer_token, customer_id)
    response = r.json()
    for number in response:
        if number['number'] == params["orderItemNumber"]:
            assert 1 == 0
        break
    r = IVR.delete_customer_numbers(data['login'], data['password'],
                                    customer_id, id_number)
    assert r.status_code == 404
Ejemplo n.º 2
0
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']
Ejemplo n.º 3
0
def test_create_scenario_with_restricted_params():
    params = [
        {
            'title': random_generator(size=129),
            'comment': 'HEH',
            'States': json.loads(json.JSONEncoder().encode(data['States']))
        },
        {
            'title': random_generator(size=128),
            'comment': random_generator(size=129),
            'States': json.loads(json.JSONEncoder().encode(data['States']))
        },
    ]
    r = IVR.create_scenario(bearer_token, data['customer_id'], params)
    assert r.status_code == 400
Ejemplo n.º 4
0
def test_create_customer_with_restricted_params():
    bearer_token = IVR.take_token(data['login'], data['password'])
    data_customer = [
        {
            'name': random_generator(42),
            'status': '1',
            'login': '******' + str(int(time.time())),
            'password': '******' + str(random.uniform(1, 2000000)),
            'email': str(int(time.time())) + '@gg.ru',
            'phone': '79777777777'
        },
        {
            'name': 'testIVR_' + str(int(time.time())),
            'status': random_generator(256),
            'login': '******' + str(int(time.time())),
            'password': '******' + str(random.uniform(1, 2000000)),
            'email': str(int(time.time())) + '@gg.ru',
            'phone': '79777777777'
        },
        {
            'name': 'testIVR_' + str(int(time.time())),
            'status': '1',
            'login': random_generator(256),
            'password': '******' + str(random.uniform(1, 2000000)),
            'email': str(int(time.time())) + '@gg.ru',
            'phone': '79777777777'
        },
        {
            'name': 'testIVR_' + str(int(time.time())),
            'status': '1',
            'login': '******' + str(int(time.time())),
            'password': random_generator(256),
            'email': str(int(time.time())) + '@gg.ru',
            'phone': '79777777777'
        },
        {
            'name': 'testIVR_' + str(int(time.time())),
            'status': '1',
            'login': '******' + str(int(time.time())),
            'password': '******' + str(random.uniform(1, 2000000)),
            'email': str(int(time.time())) + '@gg.ru',
            'phone': random_generator(256, "1234567980")
        },
    ]
    for case in data_customer:
        r = IVR.create_customer(bearer_token, params=case)
        assert r.status_code == 500
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
def test_not_exist_customer_id():
    params = {
        'title': random_generator(size=128),
        'comment': 'HEH',
        'States': data['States']
    }
    r = IVR.create_scenario(bearer_token, '7897987987987987978', params)
    assert r.status_code == 400
    response = r.json()
    assert response['message'] == 'customer doesn\'t exist'
Ejemplo n.º 7
0
def test_not_unique_scenario_title():
    params = {
        'title': random_generator(size=128),
        'comment': 'HEH',
        'States': json.loads(json.JSONEncoder().encode(data['States']))
    }
    r = IVR.create_scenario(bearer_token, data['customer_id'], params)
    assert r.status_code == 201
    r = IVR.create_scenario(bearer_token, data['customer_id'], params)
    assert r.status_code == 409
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
def test_update_scenario_with_restricted_params():
    bearer_token = IVR.take_token(data['login'], data['password'])
    params = {
        'title': random_generator(size=129),
        'comment': 'HEH',
        'States':
        json.loads(json.JSONEncoder().encode(data['States_4_update'])),
        'CommonScript': data['CommonScript']
    }
    r = IVR.update_scenario(bearer_token, customer_a_id, customer_a_scenario,
                            params)
    assert r.status_code == 400
Ejemplo n.º 10
0
def test_not_exist_scenario_id():
    bearer_token = IVR.take_token(data['login'], data['password'])
    params = {
        'title': random_generator(size=70),
        'comment': 'HEH',
        'States':
        json.loads(json.JSONEncoder().encode(data['States_4_update'])),
        'CommonScript': data['CommonScript']
    }
    r = IVR.update_scenario(bearer_token, customer_a_id, '1000000', params)
    assert r.status_code == 404
    response = r.json()
    assert response['message'] == 'resource not found'
Ejemplo n.º 11
0
def test_create_scenario():
    params = {
        'title': random_generator(size=63),
        'comment': 'HEH',
        'States': json.loads(json.JSONEncoder().encode(data['States']))
    }
    r = IVR.create_scenario(bearer_token, data['customer_id'], params)
    assert r.status_code == 201
    response = r.json()
    assert response['title'] == params['title']
    assert response['comment'] == params['comment']
    scenario = IVR.get_scenarios(bearer_token, data['customer_id'])
    assert scenario.status_code == 206
Ejemplo n.º 12
0
def test_update_foreign_scenario():
    bearer_token = IVR.take_token(data['login'], data['password'])
    params = {
        'title': random_generator(size=70),
        'comment': 'HEH',
        'States':
        json.loads(json.JSONEncoder().encode(data['States_4_update'])),
        'CommonScript': data['CommonScript']
    }
    r = IVR.update_scenario(bearer_token, customer_a_id, customer_b_scenario,
                            params)
    assert r.status_code == 403
    response = r.json()
    assert response['message'] == 'access forbidden'
Ejemplo n.º 13
0
    assert r.status_code == 201
    r = IVR.create_scenario(bearer_token, data['customer_id'], params)
    assert r.status_code == 409


@pytest.mark.parametrize('params', [
    pytest.param(
        {
            'title': '',
            'comment': 'HEH',
            'States': json.loads(json.JSONEncoder().encode(data['States']))
        },
        id='without title'),
    pytest.param(
        {
            'title': random_generator(size=128),
            'comment': 'sdfa',
            'States': ''
        },
        id='without state')
])
def test_creating_with_empty_params(params):
    r = IVR.create_scenario(bearer_token, data['customer_id'], params)
    assert r.status_code == 400


def test_not_exist_customer_id():
    params = {
        'title': random_generator(size=128),
        'comment': 'HEH',
        'States': data['States']