feat: flesh out the auth handler; add people handler
can handle the basics now: authentication, perm checks etc.
This commit is contained in:
parent
43ca404837
commit
e899d06151
12 changed files with 1031 additions and 23 deletions
|
@ -101,17 +101,17 @@ class TestAppHandler(TestCase):
|
|||
from wuttjamaican.db import model
|
||||
except ImportError:
|
||||
pytest.skip("test not relevant without sqlalchemy")
|
||||
else:
|
||||
self.assertNotIn('model', self.app.__dict__)
|
||||
self.assertIs(self.app.model, model)
|
||||
|
||||
self.assertNotIn('model', self.app.__dict__)
|
||||
self.assertIs(self.app.model, model)
|
||||
|
||||
def test_get_model(self):
|
||||
try:
|
||||
from wuttjamaican.db import model
|
||||
except ImportError:
|
||||
pytest.skip("test not relevant without sqlalchemy")
|
||||
else:
|
||||
self.assertIs(self.app.get_model(), model)
|
||||
|
||||
self.assertIs(self.app.get_model(), model)
|
||||
|
||||
def test_get_title(self):
|
||||
self.assertEqual(self.app.get_title(), 'WuttJamaican')
|
||||
|
@ -120,6 +120,44 @@ class TestAppHandler(TestCase):
|
|||
uuid = self.app.make_uuid()
|
||||
self.assertEqual(len(uuid), 32)
|
||||
|
||||
def test_get_session(self):
|
||||
try:
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
except ImportError:
|
||||
pytest.skip("test not relevant without sqlalchemy")
|
||||
|
||||
model = self.app.model
|
||||
user = model.User()
|
||||
self.assertIsNone(self.app.get_session(user))
|
||||
|
||||
Session = orm.sessionmaker()
|
||||
engine = sa.create_engine('sqlite://')
|
||||
mysession = Session(bind=engine)
|
||||
mysession.add(user)
|
||||
session = self.app.get_session(user)
|
||||
self.assertIs(session, mysession)
|
||||
|
||||
def test_get_person(self):
|
||||
people = self.app.get_people_handler()
|
||||
with patch.object(people, 'get_person') as get_person:
|
||||
get_person.return_value = 'foo'
|
||||
person = self.app.get_person('bar')
|
||||
get_person.assert_called_once_with('bar')
|
||||
self.assertEqual(person, 'foo')
|
||||
|
||||
def test_get_auth_handler(self):
|
||||
from wuttjamaican.auth import AuthHandler
|
||||
|
||||
auth = self.app.get_auth_handler()
|
||||
self.assertIsInstance(auth, AuthHandler)
|
||||
|
||||
def test_get_people_handler(self):
|
||||
from wuttjamaican.people import PeopleHandler
|
||||
|
||||
people = self.app.get_people_handler()
|
||||
self.assertIsInstance(people, PeopleHandler)
|
||||
|
||||
|
||||
class TestAppProvider(TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue