示例#1
0
def create_user(login_session):
    new_user = Accounts(username=login_session['username'],
                        email=login_session['email'])
    session.add(new_user)
    session.commit()
    user = session.query(Accounts).filter_by(
        email=login_session['email']).one()
    return user.id
示例#2
0
def test_UserClassFail(userlist, capsys):
    with capsys.disabled():
        now = datetime.datetime.utcnow()
        new_user = Accounts(username=entrylist[0],
                            password=entrylist[1],
                            created_on=now)

        assert new_user.username == userlist[0]
        assert new_user.password == userlist[1]
示例#3
0
 def setUp(self):
     db.create_all()
     test_account = Accounts(account_name="Barclays",cust_name="Rexx", balance=2000 )
     test_transaction = Transaction(transaction="Initial Balance", transaction_amount="2000", accounts=test_account )
     db.session.add(test_account)
     db.session.add(test_transaction)
     db.session.commit()
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
示例#4
0
def addAccount():
    form = HomeForm()
    if request.method == "POST":
        if form.validate_on_submit():
            new_account = Accounts(account_name=form.account.data,
                                   cust_name=form.customer.data,
                                   balance=form.balance.data)
            new_transaction = Transaction(transaction="Initial Balance",
                                          transaction_amount=form.balance.data,
                                          accounts=new_account)
            db.session.add(new_account)
            db.session.add(new_transaction)
            db.session.commit()
            return redirect(url_for("customer_home"))
    return render_template("add_account.html",
                           title="Add a new Account",
                           form=form)
def register():
    form = RegisterForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            username = form.username.data
            password = form.password.data
            unique_check = get_user(username)
            if unique_check == 0:
                new_entry = Accounts(username=username,
                                     password=password,
                                     created_on=timezone.localize(
                                         datetime.now()))
                add_entry(new_entry)
                return redirect(url_for('login'))
            else:
                flash("Username is already taken", "danger")
        else:
            flash("Error, cannot proceed with register", "danger")
    return render_template("register.html", form=form, title="Register")
示例#6
0
def createaccount():
    if request.method == 'POST':
        customerid = request.form.get('customerid')
        accountid = request.form.get('accountid')
        accounttype = request.form.get('accounttype')
        depositamount = request.form.get('depositamount')
        accountstatus = 'Active'
        message = 'Account created sucessfully'
        lastupdated = datetime.datetime.now()
        customer = Customerstatus.query.filter_by(
            customerid=customerid).first()
        if customer:
            if customer.status == 'Active':
                account = Accounts(customerid=customerid,
                                   accountid=accountid,
                                   accounttype=accounttype,
                                   balance=depositamount,
                                   status=accountstatus,
                                   message=message,
                                   lastupdated=lastupdated)
                transaction = Transactions(customerid=customer.customerid,
                                           accountid=accountid,
                                           amount=depositamount,
                                           msg="Debit",
                                           date=lastupdated)
                try:
                    db.session.add(account)
                    db.session.add(transaction)
                    db.session.commit()
                    flash('Account Added Sucessfully')
                    return redirect(url_for('home'))
                except:
                    flash('Constrains Failed')
                    return redirect(url_for('home'))
            else:
                flash('Customer Deactivated')
                return redirect(url_for('Home'))
        else:
            flash('Invalid Customerid / Account Inactive')
            return redirect(url_for('createaccount'))
    else:
        return render_template('createaccount.html')
示例#7
0
 def setUp(self):
     print("--------------------------NEXT-TEST----------------------------------------------")
     chrome_options = Options()
     chrome_options.binary_location = "/usr/bin/chromium-browser"
     chrome_options.add_argument("--headless")
     #chrome_options.add_argument('--no-sandbox')
     #chrome_options.add_argument('--disable-dev-shm-usage')
     self.driver = webdriver.Chrome(
         executable_path="/home/o_orekoya/chromedriver", 
         chrome_options=chrome_options
         )
     self.driver.get("http://localhost:5000")
     
     db.session.commit()
     db.drop_all()
     db.create_all()
     
     test_account = Accounts(account_name="Barclays",cust_name="Rexx", balance=2000 )
     test_transaction = Transaction(transaction="Buy grapes", transaction_amount="20", accounts=test_account )
     
     db.session.add(test_account)
     db.session.add(test_transaction)
     db.session.commit()