def test_first_pair_functionality_msisdn_already_exist(flask_app, db, session):
    """ verifying the first-pair doesn't allow duplicated primary MSISDN """
    complete_db_insertion(session, db, 2, '923004171565', 2, 'Note-8',
                          'Samsung', 'a1b2c3d4e5', '4G', 'AxT3pGf9', 2,
                          '310987923089461')
    complete_db_insertion(session, db, 3, '923458209871', 3, 'Note-9',
                          'Samsung', 'AaBbCcDdEe', '4G', 'GMiQ0D3w', 3,
                          '310987923089462')

    payload_1 = {
        "pair_code": 'AxT3pGf9',
        "sender_no": "923137248795",
        "operator": "zong"
    }
    res_1 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_1))
    print(res_1.data)
    payload_2 = {
        "pair_code": 'GMiQ0D3w',
        "sender_no": "923137248795",
        "operator": "zong"
    }
    res_2 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_2))
    print(res_2.data)
    if conf['supported_languages']['default_language'] == 'en':
        assert res_2.data == b"\"MSISDN already exists as Primary-Pair\""
    elif conf['supported_languages']['default_language'] == 'es':
        assert res_2.data == b"\"MSISDN ya existe como par primario\""
    elif conf['supported_languages']['default_language'] == 'id':
        assert res_2.data == b"\"MSISDN sudah ada sebagai Pasangan Primer\""
def test_first_pair_validations_valid_sender_no(flask_app, db, session):
    """ Verify that first-pair api responds corectly when sender_no is valid """

    complete_db_insertion(session, db, 999, '923004107404', 999, 'OnePlus5',
                          'OnePlus', 'abcdef999', '4G', 'CACF0999', 999,
                          '111111111111111')
    sender_no = '923008173629'
    payload = {
        "pair_code": "CACF0999",
        "sender_no": sender_no,
        "operator": "jazz"
    }
    rslt = flask_app.post(FIRST_PAIR_API,
                          headers=HEADERS,
                          data=json.dumps(payload))
    data = json.loads(rslt.data.decode('utf-8'))
    print(data)
    if conf['supported_languages']['default_language'] == 'en':
        assert data == "PairCode CACF0999 is valid and your pair will be added in next 24 to 48 hours"
        assert not data == "MSISDN format is not correct"
    elif conf['supported_languages']['default_language'] == 'es':
        assert data == "PairCode CACF0999 es válido y su par se agregará en las próximas 24 a 48 horas"
        assert not data == "El formato MSISDN no es correcto"
    elif conf['supported_languages']['default_language'] == 'id':
        assert data == "PairCode CACF0999 valid dan pasangan Anda akan ditambahkan dalam 24 hingga 48 jam ke depan"
        assert not data == "Format MSISDN tidak benar"
Ejemplo n.º 3
0
def test_first_pair_functionality_msisdn_already_exist(flask_app, db, session):
    """ verifying the first-pair doesn't allow duplicated primary MSISDN """
    complete_db_insertion(session, db, 2, '923004171565', 2, 'Note-8',
                          'Samsung', 'a1b2c3d4e5', '4G', 'AxT3pGf9', 2,
                          '310987923089461')
    complete_db_insertion(session, db, 3, '923458209871', 3, 'Note-9',
                          'Samsung', 'AaBbCcDdEe', '4G', 'GMiQ0D3w', 3,
                          '310987923089462')

    payload_1 = {
        "Pair_Code": 'AxT3pGf9',
        "Sender_No": "923137248795",
        "Operator": "zong"
    }
    res_1 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_1))
    print(res_1.data)
    payload_2 = {
        "Pair_Code": 'GMiQ0D3w',
        "Sender_No": "923137248795",
        "Operator": "zong"
    }
    res_2 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_2))
    print(res_2.data)
    assert res_2.data == b"\"MSISDN already exists as Primary-Pair\""
def test_first_pair_functionality_invalid_paircode(flask_app, db, session):
    """ verifying the first-pair doesn't allow invalid pair-code or paircode not found in DB """
    complete_db_insertion(session, db, 4, '923004171565', 4, 'S-8', 'Samsung',
                          'a1b2c3d4uu', '3G,4G', 'A1b2C3d4', 4,
                          '310987923083344')
    complete_db_insertion(session, db, 5, '923458209871', 5, 'S-9', 'Samsung',
                          'AaBbCcDdvv', '3G,4G', 'GMiCTD3w', 5,
                          '310987923086789')

    payload_1 = {
        "pair_code": 'A1b2C3d4',
        "sender_no": "923146398444",
        "operator": "zong"
    }
    res_1 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_1))
    print(res_1.data)

    payload_2 = {
        "pair_code": 'A1b2C3d4',
        "sender_no": "923218450713",
        "operator": "warid"
    }
    res_2 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_2))
    data_2 = json.loads(res_2.data.decode('utf-8'))
    print(data_2)
    if conf['supported_languages']['default_language'] == 'en':
        assert data_2 == "Pair Code A1b2C3d4 is not Valid"
    elif conf['supported_languages']['default_language'] == 'es':
        assert data_2 == "El código de par A1b2C3d4 no es válido"
    elif conf['supported_languages']['default_language'] == 'id':
        assert data_2 == "Kode Pair A1b2C3d4 Tidak Valid"

    payload_3 = {
        "pair_code": 'AaBbCcDd',
        "sender_no": "923339014785",
        "operator": "warid"
    }
    res_3 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_3))
    data_3 = json.loads(res_3.data.decode('utf-8'))
    print(res_3.data)
    if conf['supported_languages']['default_language'] == 'en':
        assert data_3 == "Pair Code AaBbCcDd is not Valid"  # pair-code not in database
    elif conf['supported_languages']['default_language'] == 'es':
        assert data_3 == "El código de par AaBbCcDd no es válido"
    elif conf['supported_languages']['default_language'] == 'id':
        assert data_3 == "Kode Pair AaBbCcDd Tidak Valid"
def test_first_pair_happy_case(flask_app, db, session):
    """ Verify that first-pair api responds correctly when all parameters are valid"""
    from tests._helpers import complete_db_insertion
    # url = 'api/v1/first-pair'
    # HEADERS = {'Content-Type': "application/json"}
    complete_db_insertion(session, db, 1, '923004171564', 1, 'Note5',
                          'Samsung', 'abcdefgh', '4G', 'OvfT4pGf', 1,
                          '123456789098765')

    payload = {
        "pair_code": 'OvfT4pGf',
        "sender_no": "923040519777",
        "operator": "jazz"
    }
    rslt = flask_app.post(FIRST_PAIR_API,
                          headers=HEADERS,
                          data=json.dumps(payload))
    print(rslt.data)
    assert rslt.status_code == 200
    return rslt.data
Ejemplo n.º 6
0
def test_first_pair_functionality_invalid_paircode(flask_app, db, session):
    """ verifying the first-pair doesn't allow duplicated pair-code or paircode not found in DB """
    complete_db_insertion(session, db, 4, '923004171565', 4, 'S-8', 'Samsung',
                          'a1b2c3d4uu', '3G,4G', 'A1b2C3d4', 4,
                          '310987923083344')
    complete_db_insertion(session, db, 5, '923458209871', 5, 'S-9', 'Samsung',
                          'AaBbCcDdvv', '3G,4G', 'GMiCTD3w', 5,
                          '310987923086789')

    payload_1 = {
        "Pair_Code": 'A1b2C3d4',
        "Sender_No": "923146398444",
        "Operator": "zong"
    }
    res_1 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_1))
    print(res_1.data)
    payload_2 = {
        "Pair_Code": 'A1b2C3d4',
        "Sender_No": "923218450713",
        "Operator": "warid"
    }
    res_2 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_2))
    print(res_2.data)
    assert res_2.data == b"\"Pair Code (A1b2C3d4) is not Valid\""
    payload_3 = {
        "Pair_Code": 'AaBbCcDd',
        "Sender_No": "923339014785",
        "Operator": "warid"
    }
    res_3 = flask_app.post(FIRST_PAIR_API,
                           headers=HEADERS,
                           data=json.dumps(payload_3))
    print(res_3.data)
    assert res_3.data == b"\"Pair Code (AaBbCcDd) is not Valid\""  # pair-code not in database