<s> import unittest <EOL> from webtools . database import Base <EOL> from webtools . auth . models import User <EOL> from . settings import TestOverwriteSettings <EOL> class AuthDatabaseTest ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> from webtools . application import Application <EOL> cls . app = Application ( TestOverwriteSettings ( ) ) <EOL> Base . metadata . create_all ( cls . app . engine ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> Base . metadata . drop_all ( cls . app . engine ) <EOL> def tearDown ( self ) : <EOL> self . app . db . query ( User ) . delete ( ) <EOL> self . app . db . commit ( ) <EOL> def test_authenticate ( self ) : <EOL> u = User ( username = "<STR_LIT:foo>" , first_name = "<STR_LIT>" , last_name = "<STR_LIT>" , email = "<STR_LIT>" ) <EOL> u . set_password ( "<STR_LIT:bar>" ) <EOL> self . app . db . add ( u ) <EOL> authenticated_user = self . app . _authenticate ( username = "<STR_LIT:foo>" , password = "<STR_LIT:bar>" ) <EOL> self . assertEqual ( u . id , authenticated_user . id ) </s>
