def test_get_by_id(self): from horus.tests.models import Group from horus.tests.models import User group = Group(name='admin', description='group for admins') group2 = Group(name='employees', description='group for employees') self.session.add(group) self.session.add(group2) self.session.commit() request = testing.DummyRequest() group = Group.get_by_id(request, group2.id) assert group.name == 'employees'
def test_get_all(self): from horus.tests.models import Group from horus.tests.models import User user = User(username='******', email='*****@*****.**') user.password = '******' self.session.add(user) group = Group(name='admin', description='group for admins') group.users.append(user) self.session.add(group) self.session.commit() request = testing.DummyRequest() groups = Group.get_all(request) assert len(groups.all()) == 1
def test_get_by_id(self): from horus.tests.models import Group group = Group(name='admin', description='group for admins') group2 = Group(name='employees', description='group for employees') self.session.add(group) self.session.add(group2) self.session.commit() request = testing.DummyRequest() group = Group.get_by_id(request, group2.id) assert group.name == 'employees'
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_init(self): from horus.tests.models import Group group = Group(name='foo', description='bar') assert group.name == 'foo' assert group.description == 'bar'