first tests passing

master
Daniel Knüttel 2018-07-15 10:50:05 +02:00
parent 4bba2167c1
commit 7d8532f5cf
3 changed files with 10 additions and 8 deletions

View File

@ -1,3 +1,3 @@
webdb webdb
cherrypy cherrypy
pytest

View File

@ -13,7 +13,7 @@ class RegistrationServer(object):
return open(self.conf["register"]["index"]) return open(self.conf["register"]["index"])
@cherrypy.expose @cherrypy.expose
@cherrypy.tools.json_in @cherrypy.tools.json_in()
def do_register(self): def do_register(self):
if(not self.conf["register"]["enabled"]): if(not self.conf["register"]["enabled"]):
@ -37,7 +37,7 @@ class RegistrationServer(object):
"email, first_name, last_name) "\ "email, first_name, last_name) "\
"VALUES(?, ?, ?, ?, ?)", "VALUES(?, ?, ?, ?, ?)",
[username, passwd_hash, data["email"], [username, passwd_hash, data["email"],
data["first_name"], data["last_name"]) data["first_name"], data["last_name"]])
db.commit() db.commit()
db.close() db.close()

View File

@ -1,4 +1,6 @@
import os
from hashlib import sha256 from hashlib import sha256
import sqlite3
from server.registration import RegistrationServer from server.registration import RegistrationServer
@ -40,7 +42,7 @@ def build_dir(directory):
cursor.execute("CREATE TABLE confirmations_awaiting(" \ cursor.execute("CREATE TABLE confirmations_awaiting(" \
"user_id integer, " \ "user_id integer, " \
"convirmation_id integer PRIMARY KEY AUTOINCREMENT"); "convirmation_id integer PRIMARY KEY AUTOINCREMENT)")
db.commit() db.commit()
cursor.execute("CREATE INDEX username ON users(username)") cursor.execute("CREATE INDEX username ON users(username)")
@ -107,11 +109,11 @@ def build_dir(directory):
create_private_db(directory) create_private_db(directory)
create_public_db(directory) create_public_db(directory)
with open("index.html", "w") as index: with open(os.path.join(directory, "index.html"), "w") as index:
index.write("INDEX") index.write("INDEX")
return {"database": {"users": directory + "private"}, return {"database": {"users": os.path.join(directory, "private")},
"register": {"index": directory + "index.html", "register": {"index": os.path.join(directory, "index.html"),
"enabled": True} "enabled": True}
} }
@ -125,5 +127,5 @@ def test_registration(tmpdir):
server = RegistrationServer(conf, mkhash) server = RegistrationServer(conf, mkhash)
assert server.index() == "INDEX" assert server.index().read() == "INDEX"