def test_it(self): user = sa_model.DBSession.query(sa_model.User).filter(sa_model.User.user_name == u"rms").one() identity = {"repoze.who.userid": user.user_name} expected_identity = {"repoze.who.userid": user.user_name, "user": user} plugin = SQLAlchemyUserMDPlugin(sa_model.User, sa_model.DBSession) plugin.add_metadata(None, identity) self.assertEqual(identity, expected_identity)
class TestMDProviderWithTranslations(unittest.TestCase): """Tests for the translation functionality""" def setUp(self): databasesetup_sa.setup_database_with_translations() def tearDown(self): databasesetup_sa.teardownDatabase() def test_it(self): self.plugin = SQLAlchemyUserMDPlugin(sa_model.Member, sa_model.DBSession) # Updating the translations... self.plugin.translations['user_name'] = 'member_name' # Testing it... member = sa_model.DBSession.query(sa_model.Member).\ filter(sa_model.Member.member_name==compat.u('rms')).one() identity = {'repoze.who.userid': member.member_name} expected_identity = { 'repoze.who.userid': member.member_name, 'user': member} self.plugin.add_metadata(None, identity) self.assertEqual(expected_identity.keys(), identity.keys()) self.assertEqual( expected_identity['repoze.who.userid'], identity['repoze.who.userid'], ) self.assertEqual( expected_identity['user'].member_name, identity['user'].member_name, )
class TestMDProviderWithTranslations(unittest.TestCase): """Tests for the translation functionality""" def setUp(self): databasesetup_sa.setup_database_with_translations() def tearDown(self): databasesetup_sa.teardownDatabase() def test_it(self): self.plugin = SQLAlchemyUserMDPlugin(sa_model.Member, sa_model.DBSession) # Updating the translations... self.plugin.translations['user_name'] = 'member_name' # Testing it... member = sa_model.DBSession.query(sa_model.Member).\ filter(sa_model.Member.member_name==compat.u('rms')).one() identity = {'repoze.who.userid': member.member_name} expected_identity = { 'repoze.who.userid': member.member_name, 'user': member } self.plugin.add_metadata(None, identity) self.assertEqual(expected_identity.keys(), identity.keys()) self.assertEqual( expected_identity['repoze.who.userid'], identity['repoze.who.userid'], ) self.assertEqual( expected_identity['user'].member_name, identity['user'].member_name, )
class TestMDProvider(unittest.TestCase): """Tests for the authenticator function""" def setUp(self): databasesetup_sa.setup_database() self.plugin = SQLAlchemyUserMDPlugin(sa_model.User, sa_model.DBSession) def tearDown(self): databasesetup_sa.teardownDatabase() def test_implements(self): verifyClass(IMetadataProvider, SQLAlchemyUserMDPlugin, tentative=True) def test_it(self): user = sa_model.DBSession.query(sa_model.User).\ filter(sa_model.User.user_name==compat.u('rms')).one() identity = {'repoze.who.userid': user.user_name} expected_identity = { 'repoze.who.userid': user.user_name, 'user': user} self.plugin.add_metadata(None, identity) self.assertEqual(identity.keys(), expected_identity.keys()) self.assertEqual( expected_identity['repoze.who.userid'], identity['repoze.who.userid'], ) self.assertEqual( expected_identity['user'].user_name, identity['user'].user_name, ) def test_rollback(self): """The session must be rolled back before use.""" # Make the transaction invalid by attempting to add an existing user: try: user = sa_model.User() user.user_name = compat.u("rms") user.password = "******" sa_model.DBSession.add(user) sa_model.DBSession.commit() except IntegrityError: pass else: self.fail("An IntegrityError must've been raised") identity = {'repoze.who.userid': compat.u("rms")} self.plugin.add_metadata(None, identity)
class TestMDProviderWithTranslations(BaseDMTester): """Tests for the translation functionality""" def setUp(self): databasesetup_sa.setup_database_with_translations() def test_it(self): self.plugin = SQLAlchemyUserMDPlugin(sa_model.Member, sa_model.DBSession) # Updating the translations... self.plugin.translations["user_name"] = "member_name" # Testing it... member = sa_model.DBSession.query(sa_model.Member).filter(sa_model.Member.member_name == u"rms").one() identity = {"repoze.who.userid": member.member_name} expected_identity = {"repoze.who.userid": member.member_name, "user": member} self.plugin.add_metadata(None, identity) self.assertEqual(expected_identity, identity)
class TestMDProvider(unittest.TestCase): """Tests for the authenticator function""" def setUp(self): databasesetup_sa.setup_database() self.plugin = SQLAlchemyUserMDPlugin(sa_model.User, sa_model.DBSession) def tearDown(self): databasesetup_sa.teardownDatabase() def test_implements(self): verifyClass(IMetadataProvider, SQLAlchemyUserMDPlugin, tentative=True) def test_it(self): user = sa_model.DBSession.query(sa_model.User).\ filter(sa_model.User.user_name==compat.u('rms')).one() identity = {'repoze.who.userid': user.user_name} expected_identity = {'repoze.who.userid': user.user_name, 'user': user} self.plugin.add_metadata(None, identity) self.assertEqual(identity.keys(), expected_identity.keys()) self.assertEqual( expected_identity['repoze.who.userid'], identity['repoze.who.userid'], ) self.assertEqual( expected_identity['user'].user_name, identity['user'].user_name, ) def test_rollback(self): """The session must be rolled back before use.""" # Make the transaction invalid by attempting to add an existing user: try: user = sa_model.User() user.user_name = compat.u("rms") user.password = "******" sa_model.DBSession.add(user) sa_model.DBSession.commit() except IntegrityError: pass else: self.fail("An IntegrityError must've been raised") identity = {'repoze.who.userid': compat.u("rms")} self.plugin.add_metadata(None, identity)
class TestMDProvider(unittest.TestCase): """Tests for the authenticator function""" def setUp(self): databasesetup_sa.setup_database() self.plugin = SQLAlchemyUserMDPlugin(sa_model.User, sa_model.DBSession) def tearDown(self): databasesetup_sa.teardownDatabase() def test_implements(self): verifyClass(IMetadataProvider, SQLAlchemyUserMDPlugin, tentative=True) def test_it(self): user = sa_model.DBSession.query(sa_model.User).\ filter(sa_model.User.user_name==u'rms').one() identity = {'repoze.who.userid': user.user_name} expected_identity = {'repoze.who.userid': user.user_name, 'user': user} self.plugin.add_metadata(None, identity) self.assertEqual(identity, expected_identity)
class TestMDProvider(unittest.TestCase): """Tests for the authenticator function""" def setUp(self): databasesetup_sa.setup_database() self.plugin = SQLAlchemyUserMDPlugin(sa_model.User, sa_model.DBSession) def tearDown(self): databasesetup_sa.teardownDatabase() def test_implements(self): verifyClass(IMetadataProvider, SQLAlchemyUserMDPlugin, tentative=True) def test_it(self): user = sa_model.DBSession.query(sa_model.User).\ filter(sa_model.User.user_name==u'rms').one() identity = {'repoze.who.userid': user.user_name} expected_identity = { 'repoze.who.userid': user.user_name, 'user': user} self.plugin.add_metadata(None, identity) self.assertEqual(identity, expected_identity)