<s> from nose . tools import * <EOL> from framework . sessions import utils <EOL> from tests import factories <EOL> from tests . base import DbTestCase <EOL> from website . models import User <EOL> from website . models import Session <EOL> class SessionUtilsTestCase ( DbTestCase ) : <EOL> def setUp ( self , * args , ** kwargs ) : <EOL> super ( SessionUtilsTestCase , self ) . setUp ( * args , ** kwargs ) <EOL> self . user = factories . UserFactory ( ) <EOL> def tearDown ( self , * args , ** kwargs ) : <EOL> super ( SessionUtilsTestCase , self ) . tearDown ( * args , ** kwargs ) <EOL> User . remove ( ) <EOL> Session . remove ( ) <EOL> def test_remove_session_for_user ( self ) : <EOL> factories . SessionFactory ( user = self . user ) <EOL> assert_equal ( <NUM_LIT:1> , Session . find ( ) . count ( ) ) <EOL> utils . remove_sessions_for_user ( self . user ) <EOL> assert_equal ( <NUM_LIT:0> , Session . find ( ) . count ( ) ) <EOL> factories . SessionFactory ( ) <EOL> factories . SessionFactory ( user = self . user ) <EOL> assert_equal ( <NUM_LIT:2> , Session . find ( ) . count ( ) ) <EOL> utils . remove_sessions_for_user ( self . user ) <EOL> assert_equal ( <NUM_LIT:1> , Session . find ( ) . count ( ) ) <EOL> def test_password_change_clears_sessions ( self ) : <EOL> factories . SessionFactory ( user = self . user ) <EOL> factories . SessionFactory ( user = self . user ) <EOL> factories . SessionFactory ( user = self . user ) <EOL> assert_equal ( <NUM_LIT:3> , Session . find ( ) . count ( ) ) <EOL> self . user . set_password ( '<STR_LIT>' ) <EOL> assert_equal ( <NUM_LIT:0> , Session . find ( ) . count ( ) ) </s>
