How to use format_times method in stestr

Best Python code snippet using stestr_python

calc_time.py

Source:calc_time.py Github

copy

Full Screen

1from datetime import datetime23def day_formatter(start_time, end_time, lunch_start, lunch_end, total_time):4 width = 245 l1_l = 'Start Time:'.ljust(width - 4)6 l1_r = start_time.strftime('%H%M')7 l2_l = 'Lunch Start Time:'.ljust(width - 4)8 l2_r = lunch_start.strftime('%H%M')9 l3_l = 'Lunch End Time:'.ljust(width - 4)10 l3_r = lunch_end.strftime('%H%M')11 l4_l = 'End Time:'.ljust(width - 4)12 l4_r = end_time.strftime('%H%M')13 l5_l = 'Total Time:'.ljust(width - 4)14 l5_r = str(total_time)[:-3]1516 print()17 print("=" * width)18 print(l1_l + l1_r)19 print(l2_l + l2_r)20 print(l3_l + l3_r)21 print(l4_l + l4_r)22 print()23 print(l5_l + l5_r)24 print("=" * width)25 print()2627def calc_time():28 print('Enter all times as four digit 24 hr times without colons (e.g. "1415").')29 start_time = str(input('Enter start time: '))30 lunch_start = str(input('Enter lunch start time: '))31 if lunch_start not in ['n', '']:32 lunch_end = str(input('Enter lunch end time: '))33 else:34 lunch_start = '0000'35 lunch_end = '0000'36 end_time = str(input('Enter end time: '))37 38 times = [start_time, lunch_start, lunch_end, end_time]39 try:40 format_times = [datetime.strptime(time, '%H%M') for time in times]41 total_time = format_times[3] - format_times[0] - (format_times[2] - format_times[1])42 day_formatter(format_times[0], format_times[3], format_times[1], format_times[2], total_time)43 except ValueError:44 print()45 print('Entered time formats are invalid. Please enter times as "HHMM".')46 calc_time()47 input('Press ENTER to exit...')4849if __name__ == '__main__': ...

Full Screen

Full Screen

app.py

Source:app.py Github

copy

Full Screen

...12@app.route("/calculate_balance", methods=['POST'])13def calculate_balance():14 args = request.get_json(force=True)15 print(args)16 start_time = format_times(args.get('start_time'))17 end_time = format_times(args.get('end_time'))18 bed_time = format_times(args.get('bed_time'))19 20 print(start_time, end_time, bed_time)21 calculation = calculate_nightly_charge(start_time, end_time, bed_time)22 return jsonify(calculation)23if __name__ == '__main__':...

Full Screen

Full Screen

test_format_times.py

Source:test_format_times.py Github

copy

Full Screen

...5from backend.calculate_charge import format_times6TODAY = datetime.today()7TOMORROW = datetime.today() + timedelta(days=1)8def test_format_regular_first_leg():9 formatted = format_times('18:00')10 assert(formatted == TODAY.replace(hour=18, minute=0, second=0, microsecond=0))11def test_format_regular_last_leg():12 formatted = format_times('04:00')13 assert(formatted == TOMORROW.replace(hour=4, minute=0, second=0, microsecond=0))14def test_format_none():15 formatted = format_times(None)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stestr automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful