Files
@ 93889b9694f4
Branch filter:
Location: rattail-project/rattail/tests/test_auth.py - annotation
93889b9694f4
1.8 KiB
text/x-python
bump: version 0.18.12 → 0.19.0
301fce831c4d 301fce831c4d 301fce831c4d 301fce831c4d 1641e0ea14d6 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 1641e0ea14d6 446a63b6ebbf 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 446a63b6ebbf 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 1a3693fd10cf 9fcbdb023c5d 446a63b6ebbf 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 1a3693fd10cf 1a3693fd10cf 9fcbdb023c5d 1a3693fd10cf 1a3693fd10cf 9fcbdb023c5d 1a3693fd10cf 1a3693fd10cf 9fcbdb023c5d 1a3693fd10cf 1a3693fd10cf 1a3693fd10cf 1a3693fd10cf 1a3693fd10cf 9fcbdb023c5d 1a3693fd10cf | # -*- coding: utf-8; -*-
from unittest import TestCase
from rattail.config import RattailConfig
try:
import sqlalchemy as sa
from rattail import auth as mod
from rattail.db import Session
except ImportError:
pass
else:
class TestAuthHandler(TestCase):
def setUp(self):
self.config = RattailConfig()
self.app = self.config.get_app()
self.handler = self.make_handler()
def make_handler(self):
return mod.AuthHandler(self.config)
def test_delete_user(self):
engine = sa.create_engine('sqlite://')
model = self.app.model
model.Base.metadata.create_all(bind=engine)
session = Session(bind=engine)
# make a user, then delete - it should work
user = model.User(username='foobar')
session.add(user)
session.commit()
self.assertIn(user, session)
self.handler.delete_user(user)
session.commit()
self.assertNotIn(user, session)
def test_user_is_admin(self):
engine = sa.create_engine('sqlite://')
model = self.app.model
model.Base.metadata.create_all(bind=engine)
session = Session(bind=engine)
# no user
self.assertFalse(self.handler.user_is_admin(None))
# real user but not an admin
user = model.User(username='barney')
session.add(user)
session.commit()
self.assertFalse(self.handler.user_is_admin(user))
# but if they are admin, it shows
admin = self.handler.get_role_administrator(session)
user.roles.append(admin)
session.commit()
self.assertTrue(self.handler.user_is_admin(user))
session.close()
|