Пример #1
0
    def test_reg_normal(self):
        # 环境检查及数据准备
        conn = get_conn()
        result = query_db(
            conn, "select id from user where name='{}'".format(NEW_USER))
        print(result)
        if result:
            change_db(conn,
                      "delete from user where name='{}'".format(NEW_USER))

        # 组装和发送请求
        url = "http://115.28.108.130:5000/api/user/reg/"
        data = {"name": NEW_USER, "password": "******"}
        res = requests.post(url=url, json=data)
        print(res.json())
        res_dict = res.json()
        # 断言
        self.assertEqual("100000", res_dict["code"])
        self.assertEqual("成功", res_dict["msg"])
        self.assertEqual(NEW_USER, res_dict["data"]["name"])
        # 数据库断言
        result2 = query_db(
            conn, "select * from user where name='{}'".format(NEW_USER))
        name = result2[0][1]
        self.assertEqual(NEW_USER, name)

        # 环境清理
        change_db(conn, "delete from user where name='{}'".format(NEW_USER))
        conn.close()
Пример #2
0
def video_table():
    db = get_conn()
    cur = db.cursor()
    cur.execute(
        'select id,tch_id,stu_id,training_start,training_end,current_stage,stu_swapped_url from faceswap'
    )
    data = cur.fetchall()
    cur.close()
    data = list(data)
    table_html = '<tr><th>ID</th><th>TchID</th><th>StuID</th><th>ProcessState</th><th>trainingStart</th><th>trainingEnd</th><th>Button</th></tr>'
    for i in data:
        i = list(i)
        i[-1] = '<a href="' + str(
            i[-1]
        ) + '" class="videoPlayBtn" style="text-decoration:none;">Play</a>'
        table_html += '<tr><th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th><th>{5}</th><th>{6}</th></tr>'.format(
            i[0], i[1], i[2], i[3], i[4], i[5], i[6])
    return render_template('memList.html', data=table_html)
Пример #3
0
    def test_reg_normal(self):
        # 环境检查及数据准备
        conn = get_conn()
        result = query_db(
            conn, "select id from user where name ='{}'".format(NEW_USER))
        if result:
            change_db(conn,
                      "delete from  `user` where name = '{}'".format(NEW_USER))

        # 组装和发送请求
        url = "http://115.28.108.130:5000/api/user/reg/"
        data = {"name": NEW_USER, "password": "******"}
        res = requests.post(url=url, json=data)
        res_dict = res.json()
        print(res.json())
        # 断言,传两个参数,assert代表期望结果,Equal代表实际结果
        self.assertEqual("100000", res_dict["code"])
        self.assertEqual("成功", res_dict["msg"])
        self.assertEqual("SHM9", res_dict["data"]["name"])
Пример #4
0
"""用例辅助方法"""
import requests
from lib.db import query_db, change_db


def get_user_data(conn, name):
    result = query_db(conn, "select * from user where name='{}'".format(name))
    return result


# delete from user where name="{}".format(name)
def del_user(conn, name):
    change_db(conn, 'delete from user where name="{}"'.format(name))


def login(name, password):
    s = requests.session()
    url = "http://115.28.108.130:5000/api/user/login/"
    data = {"name": name, "password": password}
    s.post(url=url, data=data)
    return s


if __name__ == "__main__":
    from lib.db import get_conn
    conn = get_conn()
    print(get_user_data(conn, "张三"))
    conn.close()
Пример #5
0
import csv

sys.path.append(os.path.abspath('..'))
from lib import db


# type: 0: unknown, 1:country, 2:city, 4:spot
types = dict(
    unknown=0,
    country=1,
    city=2,
    spot=4,
)

if __name__ == '__main__':
    conn = db.get_conn()
    with open('/Users/nanfang/places.csv', 'r') as f:
        r = csv.reader(f)
        header = True
        for name,name_en,slug,parent_slug,type,latitude,longitude in r:
            name = unicode(name,"utf-8")
            name_en = unicode(name_en,"utf-8")
            if header:
                header = False
                continue
            if latitude and longitude:
                db.execute_sql(conn,"""
                    INSERT INTO place(name,name_en,slug,type,location) values
                    (%%s,%%s,%%s,%%s,ST_GeomFromText('POINT(%s %s)', 4326))
                    """ % (longitude, latitude)
                    , (name,name_en,slug,types.get(type,0))
Пример #6
0
def recall_next_action(name):
    conn = db.get_conn()
    return _recall_next_action(name, conn)
Пример #7
0
def recall_next_actions():
    conn = db.get_conn()
    return _recall_next_actions(conn)
Пример #8
0
 def test_reg_with_exist_user(self):
     conn = get_conn()
Пример #9
0
 def setUpClass(cls):
     cls.conn = get_conn()
     cls.url = "http://115.28.108.130:5000/api/user/reg/"
Пример #10
0
    # add mime type for raw images
    mimetypes.add_type('image/raw', '.CR2')

    # directories
    source_dir = app.config.get('directories', 'photos')
    database_file = app.config.get('database', 'file')

    database = db.init(database_file)

    # 1. check for deleted files
    print 'Check for deleted files'

    cursor = db.fetch('SELECT id, path FROM photos')
    for row in cursor.fetchall():
        if not os.path.exists(os.path.join(source_dir, row[1])):
            db.get_conn().execute('DELETE FROM photos WHERE id = ?', row[0])
            sys.stdout.write('X')
        else:
            sys.stdout.write('.')
        sys.stdout.flush()

    print

    db.get_conn().commit()

    # 2. add new files
    print 'Add new files'

    skip_files = ['.DS_Store']
    image_types = ['image/jpeg', 'image/raw']
Пример #11
0
def get_user_data(conn, name):
    conn = get_conn()
    result = query_db(conn,
                      "select * from user where name = '{}'".format(name))
    return result