def test_validate_date_correctformat(self): input_data = [ '2020-01-01', '', '01/01/2010', '2010', '2010-01', '01-01' ] expected_results = [True, False, False, False, False, False] for data, expected in zip(input_data, expected_results): result = validate.validate_date(data) print(f"validate_date ({data}) == {expected}?") self.assertEqual(expected, result)
def print_statement(id): try: acc_no = int(input("Enter your account No\n")) except: print("Invalid Account No") return account = database.get_all_info_account(acc_no,id,"statement") if account is not None: print("Enter Dates in format (day-Mon-Year) ") date_from = input("Date From : ") date_to = input("\nDate To : ") if validate.validate_date(date_from,date_to) == True: res = database.get_transactions_account(acc_no,date_from,date_to) print("Date \t\t\t Transaction Type \t\t\t Amount \t\t\t Balance \t") for i in range(0,len(res)): print(res[i][0].strftime("%d-%b-%Y")," \t\t\t ",res[i][1]," \t\t\t ",res[i][2]," \t\t\t ",res[i][3]) else: print("Please Enter Valid Dates")
def print_statement(self): try: acc_no = int(input("Enter your account No\n")) except: print("Invalid Account No") return account = database.get_all_info_account(acc_no, self.id, "statement") if account is not None: print("Enter Dates in format (Year-Mon-Day) ") date_from = input("Date From : ") date_to = input("Date To : ") if validate.validate_date(date_from, date_to): res = database.get_transactions_account( acc_no, date_from, date_to) print( tabulate(res, headers=[ "Date", "Transaction Type", "Amount", "Balance", "Account Type" ], tablefmt="pretty")) else: print("Please Enter Valid Dates")
import argparse import app import parser from validate import validate_date # ps = argparse.ArgumentParser(description='scraping airbnb and booking') ps.add_argument('destination', metavar='DESTINATION', type=str, nargs=None, help='destination') ps.add_argument('checkin', metavar='YYYY-MM-DD', type=str, nargs=None, help='checkin date: YYYY-MM-DD') ps.add_argument('checkout', metavar='YYYY-MM-DD', type=str, nargs=None, help='checkout date: YYYY-MM-DD') args = ps.parse_args() if __name__ == "__main__": validate_date(args.checkin) validate_date(args.checkout) app.run(args.destination, args.checkin, args.checkout) parser.run()
if validate.validate_string(details) == True: break else: print("Invalid detials, details only alphabet") while True: total_target = input( "please enter project total target: ").strip() if total_target.isdigit(): break else: print("invalid total target") while True: start_date = input( "please enter project start date (dd-mm-yyyy): " ).strip() if validate.validate_date(start_date): break else: print("invalid date input") while True: end_date = input( "please enter project end date (dd-mm-yyyy): " ).strip() if validate.validate_date(end_date): if datetime.strptime( end_date, "%d-%m-%Y") > datetime.strptime( start_date, "%d-%m-%Y"): break else: print( "------> end date must be after start date <--------"