Browse Source

in memory tests

master
Julio Biason 11 years ago
parent
commit
071bef53a2
  1. 10
      luncho/server.py
  2. 9
      tests/users_tests.py

10
luncho/server.py

@ -32,16 +32,20 @@ db = SQLAlchemy(app)
class User(db.Model): class User(db.Model):
username = db.Column(db.String, primary_key=True) username = db.Column(db.String, primary_key=True)
full_name = db.Column(db.String, nullable=False) fullname = db.Column(db.String, nullable=False)
passhash = db.Column(db.String, nullable=False) passhash = db.Column(db.String, nullable=False)
token = db.Column(db.String) token = db.Column(db.String)
issued_date = db.Column(db.Date) issued_date = db.Column(db.Date)
validated = db.Column(db.Boolean, default=False) validated = db.Column(db.Boolean, default=False)
def __init__(self, username, full_name, passhash): def __init__(self, username, fullname, passhash, token=None,
issued_date=None, validated=False):
self.username = username self.username = username
self.full_name = full_name self.fullname = fullname
self.passhash = passhash self.passhash = passhash
self.token = token
self.issued_date = issued_date
self.validated = validated
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Blueprints # Blueprints

9
tests/users_tests.py

@ -1,8 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import os
import tempfile
import unittest import unittest
import json import json
@ -13,12 +11,11 @@ class TestUsers(unittest.TestCase):
"""Test users request.""" """Test users request."""
def setUp(self): def setUp(self):
(_, name) = tempfile.mkstemp() # leave the database blank to make it in memory
server.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
server.app.config['SQLITE_FILENAME'] = name
server.app.config['TESTING'] = True server.app.config['TESTING'] = True
print server.app.config['SQLITE_FILENAME'] print server.app.config['SQLALCHEMY_DATABASE_URI']
self.app = server.app.test_client() self.app = server.app.test_client()
# def tearDown(self): # def tearDown(self):

Loading…
Cancel
Save