예제 #1
0
    def setUp(self):
        self.app = create_app(TestingConfig)
        self.client = self.app.test_client()
        db = Dbcontroller()
        db.create_tables()

        self.user = {
            "usrid": "1",
            "username": "******",
            "email": "*****@*****.**",
            "password": "******"
        }
        self.question = {
            "qnId": "1",
            "question": "What is an exception?",
            "usrid": "3"
        }
        self.answer = {
            "ansid": "1",
            "answer": "Set of rules",
            "qnid": "1",
            "usrid": "1",
            "authid": "2",
            "comment": "accepted"
        }
        self.signup = {
            "username": "******",
            "email": "*****@*****.**",
            "password": "******"
        }
        self.login = {
            "username": "******",
            "password": "******"
        }

        self.question_add = {
            "question": "What is c++?"
        }
        self.another_question = {
            "question": "What is python?"
        }
        self.answer_post = {
            "answer": "pythonic language"
        }
        self.answer_post_empty = {
            "answer": ""
        }
예제 #2
0
import re
from flask import jsonify, make_response
from dbcontroller import Dbcontroller
db = Dbcontroller()


class Users(object):
    def __init__(self, username, email, password):
        self.username = username
        self.email = email
        self.password = password

    def save(self):
        query = "INSERT INTO users(username,email,password) VALUES('{}','{}','{}') RETURNING usrid".format(
            self.username, self.email, self.password)
        return db.post_data(query)

    def get_specific_user(self, username):
        query = "SELECT * FROM users WHERE username = '******'".format(
            self.username)
        return db.get_data(query)
예제 #3
0
 def tearDown(self):
     db = Dbcontroller()
     db.drop_tables()
예제 #4
0
from api import create_app
from config import DevelopmentConfig
from dbcontroller import Dbcontroller

app = create_app(DevelopmentConfig)

if __name__ == '__main__':
    database_connection = Dbcontroller()
    database_connection.create_tables()
    app.run()