#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# super ( SensorPermissionsResolverTestCase , self ) . setUp ( ) #NEWLINE# user_1_db = UserDB ( name = '1_role_sensor_pack_grant' ) #NEWLINE# user_1_db = User . add_or_update ( user_1_db ) #NEWLINE# self . users [ 'custom_role_sensor_pack_grant' ] = user_1_db #NEWLINE# user_2_db = UserDB ( name = '1_role_sensor_grant' ) #NEWLINE# user_2_db = User . add_or_update ( user_2_db ) #NEWLINE# self . users [ 'custom_role_sensor_grant' ] = user_2_db #NEWLINE# user_3_db = UserDB ( name = 'custom_role_pack_sensor_all_grant' ) #NEWLINE# user_3_db = User . add_or_update ( user_3_db ) #NEWLINE# self . users [ 'custom_role_pack_sensor_all_grant' ] = user_3_db #NEWLINE# user_4_db = UserDB ( name = 'custom_role_sensor_all_grant' ) #NEWLINE# user_4_db = User . add_or_update ( user_4_db ) #NEWLINE# self . users [ 'custom_role_sensor_all_grant' ] = user_4_db #NEWLINE# user_5_db = UserDB ( name = 'custom_role_sensor_list_grant' ) #NEWLINE# user_5_db = User . add_or_update ( user_5_db ) #NEWLINE# self . users [ 'custom_role_sensor_list_grant' ] = user_5_db #NEWLINE# sensor_1_db = SensorTypeDB ( pack = 'test_pack_1' , name = 'sensor1' ) #NEWLINE# sensor_1_db = SensorType . add_or_update ( sensor_1_db ) #NEWLINE# self . resources [ 'sensor_1' ] = sensor_1_db #NEWLINE# sensor_2_db = SensorTypeDB ( pack = 'test_pack_1' , name = 'sensor2' ) #NEWLINE# sensor_2_db = SensorType . add_or_update ( sensor_2_db ) #NEWLINE# self . resources [ 'sensor_2' ] = sensor_2_db #NEWLINE# sensor_3_db = SensorTypeDB ( pack = 'test_pack_2' , name = 'sensor3' ) #NEWLINE# sensor_3_db = SensorType . add_or_update ( sensor_3_db ) #NEWLINE# self . resources [ 'sensor_3' ] = sensor_3_db #NEWLINE# grant_db = PermissionGrantDB ( resource_uid = self . resources [ 'pack_1' ] . get_uid ( ) , resource_type = ResourceType . PACK , permission_types = [ PermissionType . SENSOR_VIEW ] ) #NEWLINE# grant_db = PermissionGrant . add_or_update ( grant_db ) #NEWLINE# permission_grants = [ str ( grant_db . id ) ] #NEWLINE# role_3_db = RoleDB ( name = 'custom_role_sensor_pack_grant' , permission_grants = permission_grants ) #NEWLINE# role_3_db = Role . add_or_update ( role_3_db ) #NEWLINE# self . roles [ 'custom_role_sensor_pack_grant' ] = role_3_db #NEWLINE# grant_db = PermissionGrantDB ( resource_uid = self . resources [ 'sensor_3' ] . get_uid ( ) , resource_type = ResourceType . SENSOR , permission_types = [ PermissionType . SENSOR_VIEW ] ) #NEWLINE# grant_db = PermissionGrant . add_or_update ( grant_db ) #NEWLINE# permission_grants = [ str ( grant_db . id ) ] #NEWLINE# role_4_db = RoleDB ( name = 'custom_role_sensor_grant' , permission_grants = permission_grants ) #NEWLINE# role_4_db = Role . add_or_update ( role_4_db ) #NEWLINE# self . roles [ 'custom_role_sensor_grant' ] = role_4_db #NEWLINE# grant_db = PermissionGrantDB ( resource_uid = self . resources [ 'pack_1' ] . get_uid ( ) , resource_type = ResourceType . PACK , permission_types = [ PermissionType . SENSOR_ALL ] ) #NEWLINE# grant_db = PermissionGrant . add_or_update ( grant_db ) #NEWLINE# permission_grants = [ str ( grant_db . id ) ] #NEWLINE# role_4_db = RoleDB ( name = 'custom_role_pack_sensor_all_grant' , permission_grants = permission_grants ) #NEWLINE# role_4_db = Role . add_or_update ( role_4_db ) #NEWLINE# self . roles [ 'custom_role_pack_sensor_all_grant' ] = role_4_db #NEWLINE# grant_db = PermissionGrantDB ( resource_uid = self . resources [ 'sensor_1' ] . get_uid ( ) , resource_type = ResourceType . SENSOR , permission_types = [ PermissionType . SENSOR_ALL ] ) #NEWLINE# grant_db = PermissionGrant . add_or_update ( grant_db ) #NEWLINE# permission_grants = [ str ( grant_db . id ) ] #NEWLINE# role_4_db = RoleDB ( name = 'custom_role_sensor_all_grant' , permission_grants = permission_grants ) #NEWLINE# role_4_db = Role . add_or_update ( role_4_db ) #NEWLINE# self . roles [ 'custom_role_sensor_all_grant' ] = role_4_db #NEWLINE# grant_db = PermissionGrantDB ( resource_uid = None , resource_type = None , permission_types = [ PermissionType . SENSOR_LIST ] ) #NEWLINE# grant_db = PermissionGrant . add_or_update ( grant_db ) #NEWLINE# permission_grants = [ str ( grant_db . id ) ] #NEWLINE# role_5_db = RoleDB ( name = 'custom_role_sensor_list_grant' , permission_grants = permission_grants ) #NEWLINE# role_5_db = Role . add_or_update ( role_5_db ) #NEWLINE# self . roles [ 'custom_role_sensor_list_grant' ] = role_5_db #NEWLINE# user_db = self . users [ 'custom_role_sensor_pack_grant' ] #NEWLINE# role_assignment_db = UserRoleAssignmentDB ( user = user_db . name , role = self . roles [ 'custom_role_sensor_pack_grant' ] . name ) #NEWLINE# UserRoleAssignment . add_or_update ( role_assignment_db ) #NEWLINE# user_db = self . users [ 'custom_role_sensor_grant' ] #NEWLINE# role_assignment_db = UserRoleAssignmentDB ( user = user_db . name , role = self . roles [ 'custom_role_sensor_grant' ] . name ) #NEWLINE# UserRoleAssignment . add_or_update ( role_assignment_db ) #NEWLINE# user_db = self . users [ 'custom_role_pack_sensor_all_grant' ] #NEWLINE# role_assignment_db = UserRoleAssignmentDB ( user = user_db . name , role = self . roles [ 'custom_role_pack_sensor_all_grant' ] . name ) #NEWLINE# UserRoleAssignment . add_or_update ( role_assignment_db ) #NEWLINE# user_db = self . users [ 'custom_role_sensor_all_grant' ] #NEWLINE# role_assignment_db = UserRoleAssignmentDB ( user = user_db . name , role = self . roles [ 'custom_role_sensor_all_grant' ] . name ) #NEWLINE# UserRoleAssignment . add_or_update ( role_assignment_db ) #NEWLINE# user_db = self . users [ 'custom_role_sensor_list_grant' ] #NEWLINE# role_assignment_db = UserRoleAssignmentDB ( user = user_db . name , role = self . roles [ 'custom_role_sensor_list_grant' ] . name ) #NEWLINE# UserRoleAssignment . add_or_update ( role_assignment_db )