示例#1
0
 def test_init_role_baseview(self):
     role_name = 'MyRole1'
     role_perms = ['can_some_action']
     role_vms = ['SomeBaseView']
     init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     role = self.appbuilder.sm.find_role(role_name)
     self.assertIsNotNone(role)
     self.assertEqual(len(role_perms), len(role.permissions))
示例#2
0
 def test_init_role_modelview(self):
     role_name = 'MyRole2'
     role_perms = ['can_list', 'can_show', 'can_add', 'can_edit', 'can_delete']
     role_vms = ['SomeModelView']
     init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     role = self.appbuilder.sm.find_role(role_name)
     self.assertIsNotNone(role)
     self.assertEqual(len(role_perms), len(role.permissions))
示例#3
0
 def test_init_role_baseview(self):
     role_name = 'MyRole1'
     role_perms = ['can_some_action']
     role_vms = ['SomeBaseView']
     init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     role = self.appbuilder.sm.find_role(role_name)
     self.assertIsNotNone(role)
     self.assertEqual(len(role_perms), len(role.permissions))
示例#4
0
 def test_invalid_perms(self):
     role_name = 'MyRole3'
     role_perms = ['can_foo']
     role_vms = ['SomeBaseView']
     with self.assertRaises(Exception) as context:
         init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     self.assertEqual("The following permissions are not valid: ['can_foo']",
                      str(context.exception))
示例#5
0
 def test_invalid_vms(self):
     role_name = 'MyRole4'
     role_perms = ['can_some_action']
     role_vms = ['NonExistentBaseView']
     with self.assertRaises(Exception) as context:
         init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     self.assertEqual(
         "The following view menus are not valid: "
         "['NonExistentBaseView']", str(context.exception))
示例#6
0
 def test_invalid_perms(self):
     role_name = 'MyRole3'
     role_perms = ['can_foo']
     role_vms = ['SomeBaseView']
     with self.assertRaises(Exception) as context:
         init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     self.assertEqual(
         "The following permissions are not valid: ['can_foo']",
         str(context.exception))
示例#7
0
 def test_invalid_vms(self):
     role_name = 'MyRole4'
     role_perms = ['can_some_action']
     role_vms = ['NonExistentBaseView']
     with self.assertRaises(Exception) as context:
         init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     self.assertEqual("The following view menus are not valid: "
                      "['NonExistentBaseView']",
                      str(context.exception))
示例#8
0
 def test_init_role_modelview(self):
     role_name = 'MyRole2'
     role_perms = [
         'can_list', 'can_show', 'can_add', 'can_edit', 'can_delete'
     ]
     role_vms = ['SomeModelView']
     init_role(self.appbuilder.sm, role_name, role_vms, role_perms)
     role = self.appbuilder.sm.find_role(role_name)
     self.assertIsNotNone(role)
     self.assertEqual(len(role_perms), len(role.permissions))