def test_group_finder(self): from horus import groupfinder from horus.tests.models import User from horus.tests.models import Group group = Group(name='foo', description='bar') user1 = User(username='******', email='*****@*****.**') user1.set_password('foo') group.users.append(user1) self.session.add(group) self.session.add(user1) self.session.flush() request = Mock() request.user = user1 results = groupfinder(1, request) assert 'group:foo' in results assert 'user:%s' % (user1.id) in results assert len(results) == 2
def test_group_finder(self): from horus import groupfinder from horus.tests.models import User from horus.tests.models import Group group = Group(name='foo', description='bar') user1 = User(username='******', email='*****@*****.**') user1.password = '******' group.users.append(user1) self.session.add(group) self.session.add(user1) self.session.flush() request = Mock() request.user = user1 results = groupfinder(1, request) assert 'group:foo' in results assert 'user:%s' % (user1.id) in results assert len(results) == 2
def test_group_finder_no_groups(self): from horus import groupfinder from horus.tests.models import User from horus.tests.models import Group group = Group(name='foo', description='bar') user1 = User(username='******', email='*****@*****.**') user2 = User(username='******', email='*****@*****.**') user1.password = '******' user2.password = '******' group.users.append(user1) self.session.add(group) self.session.add(user1) self.session.add(user2) self.session.flush() request = Mock() request.user = user2 results = groupfinder(2, request) assert len(results) == 1 assert 'user:%s' % (user2.id) in results