<s> from nose . tools import eq_ <EOL> from kitsune . karma . templatetags . jinja_helpers import karma_titles <EOL> from kitsune . karma . models import Title <EOL> from kitsune . users . tests import TestCase , UserFactory , GroupFactory <EOL> class KarmaTitleHelperTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( KarmaTitleHelperTests , self ) . setUp ( ) <EOL> self . user = UserFactory ( ) <EOL> self . group = GroupFactory ( name = '<STR_LIT>' ) <EOL> self . user . groups . add ( self . group ) <EOL> def test_user_title ( self ) : <EOL> title = '<STR_LIT>' <EOL> t = Title ( name = title ) <EOL> t . save ( ) <EOL> t . users . add ( self . user ) <EOL> titles = karma_titles ( self . user ) <EOL> eq_ ( <NUM_LIT:1> , len ( titles ) ) <EOL> eq_ ( title , titles [ <NUM_LIT:0> ] . name ) <EOL> def test_group_title ( self ) : <EOL> title = '<STR_LIT>' <EOL> t = Title ( name = title ) <EOL> t . save ( ) <EOL> t . groups . add ( self . group ) <EOL> titles = karma_titles ( self . user ) <EOL> eq_ ( <NUM_LIT:1> , len ( titles ) ) <EOL> eq_ ( title , titles [ <NUM_LIT:0> ] . name ) <EOL> def test_user_and_group_title ( self ) : <EOL> u_title = '<STR_LIT>' <EOL> g_title = '<STR_LIT>' <EOL> t = Title ( name = u_title ) <EOL> t . save ( ) <EOL> t . users . add ( self . user ) <EOL> t = Title ( name = g_title ) <EOL> t . save ( ) <EOL> t . groups . add ( self . group ) <EOL> titles = [ k . name for k in karma_titles ( self . user ) ] <EOL> eq_ ( <NUM_LIT:2> , len ( titles ) ) <EOL> assert u_title in titles <EOL> assert g_title in titles </s>
