def test_read_data_from_excel():
    url = "http://thetestingworldapi.com/api/studentsDetails"

    # Open file
    file = open(
        '/Users/b0222643/Documents/PythonAutomationAPI/restApi/Data_Driven_TC/TestDataFIle.json',
        'r')

    # Read file and typecast in json format
    json_request = json.loads(file.read())

    # Object of the class. packagename.classname and we need to pass two arguments FileNamePath and SheetName
    obj = Library.RowCount(
        "/Users/b0222643/Documents/PythonAutomationAPI/restApi/Data_Driven_TC/Data.xlsx",
        "Sheet1")

    # Find how many columns row and keys we are having
    col = obj.fetch_column_count()
    row = obj.fetch_row_count()
    KeyList = obj.fetch_key_names()

    # Start from 2nd row because first is header
    for i in range(2, row + 1):
        updated_json_req = obj.update_req_json_data(i, json_request, KeyList)
        response = requests.post(url, updated_json_req)
        print(response)
def test_Add_multiple_data():
    api_url = "http://thetestingworldapi.com/api/studentsDetails"
    file = open("C:/Users/Ankit/Desktop/API/AddmultipleData.json")
    json_request = json.loads(file.read())

    obj = Library.Common("C:/Users/Ankit/Desktop/API/testData.xlsx", "Sheet1")
    col = obj.fetch_column_count()
    row = obj.fetch_row_count()
    keyList = obj.fetch_key_names()

    for i in range(2, row + 1):
        updated_json_request = obj.update_request_with_data(i, json_request, keyList)
        response = requests.post(api_url, updated_json_request)
        print(response)
Exemple #3
0
def test_add_multiple_students():
    #API
    API_URL = "http://thetestingworldapi.com/api/studentsDetails"
    file = open('../Test_Data/Add_Multi_Students.json', 'r')
    json_request = json.loads(file.read())

    obj = Library.Common('../Test_Data/Multi_Test_Data.xlsx', 'Sheet1')
    col = obj.fetch_column_count()
    row = obj.fetch_row_count()
    keyList = obj.fetch_key_names()

    for i in range(2, row+1):
        updated_json_request = obj.update_request_with_data(i, json_request, keyList)
        response = requests.post(API_URL, updated_json_request)
        print(response)
def test_MultipleStudent():
    API_URL = "http://thetestingworldapi.com/api/studentsDetails"
    file = open(
        'C:\\Users\\vivek\\OneDrive\\Desktop\\json\\studentDetails.json', 'r')
    json_request = json.loads(file.read())

    obj = Library.common(
        "C:/Users/vivek/OneDrive/Desktop/json/End2End/SD.xlsx", "Sheet1")
    obj.fetch_columnCount()
    obj.fetch_rowCount()
    obj.fetch_keyNames()

    for i in range(2, rows + 1):
        updated_json_request = obj.update_requestWithData(
            i, json_request, keyList)
        response = requests.post(API_URL, updated_json_request)
        print(response)
Exemple #5
0
def test_add_multiple_students():
    # API
    api_url = "http://thetestingworldapi.com/api/studentsDetails"
    f = open('C:/Users/TestingWorld/Desktop/TASK_API/AddNewStudent.json')
    json_request = json.loads(f.read())

    obj = Library.Common(
        "C:/Users/TestingWorld/Desktop/TASK_API/TestData.xlsx", "Sheet1")
    col = obj.fetch_column_count()
    row = obj.fetch_row_count()
    keyList = obj.fetch_key_names()

    for i in range(2, row + 1):
        updated_json_request = obj.update_request_with_data(
            i, json_request, keyList)
        response = requests.post(api_url, updated_json_request)
        print(response)
def test_add_multiple_students():

    #API part
    API_URL = "http://thetestingworldapi.com/api/studentsDetails"
    file = open('F:\\Python_API_Testing\\Request_json.json', 'r')
    json_request = json.loads(
        file.read())  # type casting a simple text file to json format

    obj = Library.Common('F:\\Python_API_Testing\\Api_testing.xlsx', "Sheet1")
    col = obj.fetch_column_count()
    keylist = obj.fetch_key_names()
    row = obj.fetch_row_count()

    for i in range(2, row + 1):
        updated_json_request = obj.update_request_with_data(
            i, json_request, keylist)
        response = requests.post(API_URL, updated_json_request)
        print(response)
def test_create_students_from_excel1():
    # API
    url = 'http://thetestingworldapi.com/api/studentsDetails'
    file = open('C:\\Users\\HP\\Desktop\\API\\RequestJson.json', 'r')
    json_request = json.loads(file.read())

    obj = Library.Common('C:\\Users\\HP\\Desktop\\API\\students_data.xlsx',
                         'Sheet1')
    col = obj.fetch_column_count()
    row = obj.fetch_row_count()
    keyList = obj.fetch_key_name()

    # Excel Code
    for i in range(2, row + 1):
        updated_json_request = obj.update_request_with_data(
            i, json_request, keyList)
        response = requests.post(url, updated_json_request)
        print(response.text)
Exemple #8
0
def test_add_mulitple_data():
    #API
    API_URL = "http://thetestingworldapi.com/api/studentsDetails"
    file = open(
        "/Users/farhanmohammed/PycharmProjects/pythonPyTest/TestCases1/RequestJson.json",
        'r')
    json_request = json.loads(file.read())

    obj = Library.Common(
        '/Users/farhanmohammed/PycharmProjects/pythonPyTest/TestCases1/TestData.xlsx',
        'Sheet1')  # Need to pass 2 arguments FileNamePath & SheetName
    col = obj.fetch_coulumn_count()
    row = obj.fetch_row_count()
    keylist = obj.fetch_key_name()

    for i in range(2, row + 1):
        updated_json_request = obj.update_json_request(i, json_request,
                                                       keylist)
        response = requests.post(API_URL, updated_json_request)
        print(response)
Exemple #9
0
def test_add_multiple_students():
    # Add one student
    ap_url = "http://thetestingworldapi.com/api/studentsDetails"
    f = open('/Users/abichevo/PycharmProjects/APIautomation/post_request.txt',
             'r')
    json_request = json.loads(f.read())

    # Excel code: add multiple students from Excel sheet
    obj = Library.Common(
        '/Users/abichevo/PycharmProjects/APIautomation/mult_students.xlsx',
        'Sheet1')
    col = obj.fetch_column_count()
    row = obj.fetch_row_count()
    keylist = obj.fetch_key_names()

    for i in range(2, row + 1):
        updated_json_request = obj.update_request_with_data(
            i, json_request, keylist)
        response = requests.post(ap_url, updated_json_request)
        print(response)
        assert response.status_code == 201