class AdminTest(Test): def setUp(self): Test.setUp(self) self.user = User(username="******", password="******") self.user.add() self.view = View(view_name="Test View") self.view.add()
def test_should_add_view(self): view = View( view_name="Test" ) view.add() self.assertIn(view, self.db.session)
def set_view_permissions(view_name, permission_names): view = View.search(view_name) permissions = get_permissions(permission_names) if not view: view = View( view_name=view_name ) view.add() view.add_permissions(permissions)
class TestGetAll(ViewTest): def setUp(self): ViewTest.setUp(self) self.view2 = View( view_name="Test2" ) self.view2.add() def test_should_return_list_of_all_views(self): views = View.get_all() self.assertEqual(views, [self.view, self.view2])
class UserPermissionTest(UserTest): def setUp(self): UserTest.setUp(self) self.admin_permission = Permission(permission_name="Admin") self.admin_permission.add() self.admin_view = View(view_name="Admin View") self.admin_view.add() self.admin_view.add_permission(self.admin_permission) self.admin_user = User(username="******", password="******") self.admin_user.add() self.admin_user.add_permission(self.admin_permission) self.quality_permission = Permission(permission_name="quality") self.quality_permission.add() self.quality_view = View(view_name="Quality View") self.quality_view.add() self.quality_view.add_permission(self.quality_permission) self.normal_user = User(username="******", password="******") self.normal_user.add()
class ViewTest(Test): def setUp(self): Test.setUp(self) self.view = View(view_name="Test View") self.view.add()