<commit_before>"""
API EXAMPLE TEST
1. Add new car - POST request(without url_params)
2. Get all cars - GET request(without url_params)
3. Verify car count
4. Update newly added car details -PUT request
5. Get car details -GET request(with url_params)
6. Register car - POST request(with url_params)
7. Get list of registered cars -GET
8. Verify registered cars count
9. Delete newly added car -DELETE request
"""
import os
import sys
import time
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from endpoints.API_Player import API_Player
from conf import api_example_conf as conf


#<<<<<<< HEAD
auth_details = (conf.user_name,conf.password)

def test_api_example(api_url=http://carsapi.pythonanywhere.com, auth_details=auth_details):
#=======
#def test_api_example(api_url='http://carsapi.pythonanywhere.com'):
#>>>>>>> master
    "Run api test"
    
    try:

        # Create test object
        test_obj = API_Player(url=api_url)
        expected_pass = 0
        actual_pass = -1

        # set authentication details
        username = conf.user_name
        password = <PASSWORD>
        auth_details = test_obj.set_auth_details(username, password)
        

        # add cars
        car_details = conf.car_details
        
        try:
            result_flag = test_obj.add_car(car_details=car_details,
                                          auth_details=auth_details)
            test_obj.log_result(result_flag,<commit_msg>changes to run api tests with web hosted api server<commit_after>"""
API EXAMPLE TEST
1. Add new car - POST request(without url_params)
2. Get all cars - GET request(without url_params)
3. Verify car count
4. Update newly added car details -PUT request
5. Get car details -GET request(with url_params)
6. Register car - POST request(with url_params)
7. Get list of registered cars -GET
8. Verify registered cars count
9. Delete newly added car -DELETE request
"""
import os
import sys
import time
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from endpoints.API_Player import API_Player
from conf import api_example_conf as conf


#<<<<<<< HEAD
auth_details = (conf.user_name,conf.password)

def test_api_example(api_url='http://carsapi.pythonanywhere.com', auth_details=auth_details):
#=======
#def test_api_example(api_url='http://carsapi.pythonanywhere.com'):
#>>>>>>> master
    "Run api test"
    
    try:

        # Create test object
        test_obj = API_Player(url=api_url)
        expected_pass = 0
        actual_pass = -1

        # set authentication details
        username = conf.user_name
        password = <PASSWORD>
        auth_details = test_obj.set_auth_details(username, password)
        

        # add cars
        car_details = conf.car_details
        
        try:
            result_flag = test_obj.add_car(car_details=car_details,
                                          auth_details=auth_details)
            test_obj.log_result(result_flag,
{'fraction_non_alphanumeric': 0.09402283411685695, 'fraction_numerical': 0.007387508394895903, 'mean_word_length': 2.972, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1749469', 'n_tokens_mistral': 896, 'n_tokens_neox': 873, 'n_words': 248}