Best Python code snippet using Kiwi_python
test_oatspsql.py
Source:test_oatspsql.py
...18 key2 = oatspsql.key_gen()19 key_difference = key1 != key220 key_length = len(key1) == 1221 assert key_difference == key_length22def test_create_and_delete_case():23 caseid = None24 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')25 deleted = oatspsql.delete_case(caseid)26 assert deleted is True and caseid is not None27def test_create_and_delete_case_with_solution():28 caseid = None29 caseid = oatspsql.create_case(error='test', host='test', solution='sol', description='Test', status='new')30 deleted = oatspsql.delete_case(caseid)31 assert deleted is True and caseid is not None32def test_update_case():33 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')34 updated = oatspsql.update_case(caseid, solution='New stuff')35 deleted = oatspsql.delete_case(caseid)36 assert updated is not None and caseid is not None and deleted is True37def test_update_case_state():38 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')39 updated = oatspsql.update_case(caseid, solution='New stuff', status='technician_needed')40 deleted = oatspsql.delete_case(caseid)41 assert updated is not None and caseid is not None and deleted is True42def test_take_case():43 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')44 tech_id = oatspsql.take_case(case_id=caseid, technician='techy')45 deleted = oatspsql.delete_case(caseid)46 assert caseid is not None and tech_id is not None and deleted is True47def test_get_solutions_as_string():48 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')49 sol = []50 sol = oatspsql.get_solutions_as_string(caseid)51 print sol52 deleted = oatspsql.delete_case(caseid)53 assert sol is not None and caseid is not None and deleted is True54def test_cases_of_last_day():55 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')56 cases = oatspsql.show_cases_of_last_day()57 deleted = oatspsql.delete_case(caseid)58 assert caseid is not None and len(cases) >= 1 and deleted is True59def test_open_cases():60 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')61 cases = oatspsql.numb_open_cases()62 deleted = oatspsql.delete_case(caseid)63 assert caseid is not None and cases >= 1 and deleted is True64def test_open_cases_nr():65 caseid = oatspsql.create_case(error='test', host='test', description='Test', status='new')66 cases = oatspsql.show_open_cases_nr()67 deleted = oatspsql.delete_case(caseid)...
attempted_routes_app.py
Source:attempted_routes_app.py
1### These were attempted routes to edit and analyze the local dataset post submitting CRUD jobs.2import json3from flask import Flask, request4import jobs5from datetime import datetime6app = Flask(__name__)7def getdata():8 with open("Austin_COVID-19_Complaint_Cases.json", "r") as json_data:9 userdata = json.load(json_data)10 return userdata11### Query complaints from a range of dates12@app.route('/query', methods = ['GET'])13def query():14 data = getdata()15 start_date = input('Enter start of range: ')16 end_date = input('Enter end of range: ')17 start_range = datetime.strptime(start_date, '%Y-%m-%d')18 end_range = datetime.strptime(end_date, '%Y-%m-%d')19 query_list = []20 for complaint in data:21 date = datetime.strptime(complaint['OPENDATE'], '%Y-%m-%d')22 if ((date >= start_range) and (date <= end_range)):23 query_list.append(complaint)24 print("Query completed." + "\n")25 return str(query_list)26### Select a complaint by CASENUMBER27@app.route('/select/<CASENUMBER:id>')28def select(id):29 data = getdata()30 selected_complaint = []31 for complaint in data:32 if (complaint['CASENUMBER'] == str(id)):33 print(complaint)34 return complaint35 return("")36### Delete complaints by jobid parameter37@app.route('/delete', methods=['GET'])38def delete():39 data = getdata()40 start_date = input('Enter start of range: ')41 end_date = input('Enter end of range: ')42 start_range = datetime.strptime(start_date, '%Y-%m-%d')43 end_range = datetime.strptime(end_date, '%Y-%m-%d')44 deleted_list = data45 for complaint in data:46 date = datetime.strptime(complaint['OPENDATE'], '%Y-%m-%d')47 if ((date >= start_range) and (date <= end_range)):48 delete_case = complaint['CASENUMBER']49 for deletion in deleted_list:50 if (deletion['CASENUMBER'] == delete_case):51 deleted_list.remove(deletion)52 with open('COVID-19_complaints_after_deletion.json', 'w') as f:53 json.dump(deleted_list, f, indent=2)54 return("Complaints have been deleted." + "\n")55### Count the total number of complaints56@app.route('/total', methods = ['GET'])57def total():58 data = getdata()59 number_of_complaints = len(data)60 return("Total number of COVID-19 complaints: " + str(number_of_complaints) + "\n")61if __name__ == '__main__':...
urls.py
Source:urls.py
1from django.urls import path2from . import views3urlpatterns = [4 path('', views.all_wines, name='wines'),5 path('wine/<int:wine_id>/', views.wine_detail, name='wine_detail'),6 path('cases/', views.all_cases, name='cases'),7 path('case/<int:case_id>/', views.case_detail, name='case_detail'),8 path('add_wine/', views.add_wine, name='add_wine'),9 path('add_case/', views.add_case, name='add_case'),10 path('edit_case/<int:case_id>/', views.edit_case, name='edit_case'),11 path('edit_wine/<int:wine_id>/', views.edit_wine, name='edit_wine'),12 path('delete_case/<int:case_id>/', views.delete_case, name='delete_case'),13 path('delete_wine/<int:wine_id>/', views.delete_wine, name='delete_wine'),...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!